元数据锁

【TiDB 使用环境】测试
数据库中有个别表的DDL语句总是被卡住,是什么原因?如何优化?元数据锁信息如下

mysql> SELECT * FROM mysql.tidb_mdl_view\G;
*************************** 1. row ***************************
     job_id: 24662
    db_name: saleslink_customers
 table_name: tm_customer_profile_info
      query: /* ApplicationName=DBeaver 21.1.3 - Main */ ALTER TABLE saleslink_customers.tm_customer_profile_info CHANGE qw_nickname wx_nickname varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '企微昵称'
 session_id: 1494548122
 start_time: 2025-07-22 11:40:39.297000
SQL_DIGESTS: [null,null,null,"select @@session.transaction_read_only",null,"select `id` , `customer_id` , `large_order_series_model` , `small_order_series_model` , `is_large_order` , `large_order_num` , `small_order_num` , `is_small_order` , `large_order_id` , `small_order_id` , `first_large_order_model_name` , `latest_large_order_model_name` , `first_large_order_time` , `first_small_order_time` , `latest_large_order_time` , `latest_small_order_time` , `is_deleted` , `is_delivered` , `is_invoice` , `vin` , `delivery_car_num` , `first_delivery_time` , `latest_delivery_time` , `latest_delivery_status` , `updated_time` , `updated_by` , `created_time` , `created_by` from `tm_order_statistical_info` where `is_deleted` = ? and ( `customer_id` in ( ? ) )",null,"select @@session.transaction_read_only",null,null,"select `id` , `lead_id` , `customer_id` , `follow_up_times` , `come_times` , `fail_times` , `last_due_time` , `next_due_time` , `inten_veh_list` , `fail_time` , `dealer_name` , `dealer_code` , `first_due_time` , `lead_state` , `owner_name` , `owner_id` , `is_deleted` , `updated_time` , `updated_by` , `created_time` , `created_by` from `tm_lead_basic_info` where `is_deleted` = ? and ( `customer_id` in ( ? ) )"]
1 row in set (0.04 sec)

这就是你的
image
这个dml的sql阻塞了你的
image
ddl语句啊
找到对应的会话,杀了,ddl就执行过去了

有没有什么办法能规避这种问题?或者减小DML对DDL阻塞的概率

:joy:估计只能规范操作了。尽量避免查询加事务。