长时间DDL中执行FLUSH TABLE WITH READ LOCK导致数据库无法服务

3 篇文章 0 订阅

在某项目中使用了xtrabackup来备份mysql数据库。有两次异常的DDL语句执行时间过长,导致凌晨备份时flush table with read lock锁无法释放。后续增删改操作阻塞。

flush table with read lock的官方解释如下

FLUSH TABLES WITH READ LOCK acquires a global read lock and not table locks, so it is not
subject to the same behavior as LOCK TABLES and UNLOCK TABLES with respect to table locking
and implicit commits. For example, START TRANSACTION does not release the global read lock.


当时数据库show processlist输入如下

| 388671 | XXX          | 000:000  | xxx | Query       |   85945 | Sending data                                                          | create table test_xx2 as select * from test_xx1 a where  id =10000 

| 388716 | XXX          | 0007:0007 | NULL    | Query       |   85787 | Waiting for table metadata lock                                       | show create table `XXX`.`test_xx2`                                                         |
| 389593 | XXX          | 00032:600063  | NULL    | Query       |   82644 | Waiting for table metadata lock                                       | show create table `XXX`.`test_xx2`      
| 404002 | xxx       | 000019:40003  | NULL    | Query    |   29001 | Waiting for global read lock                                          | FLUSH TABLES WITH READ LOCK                                                                          |
| 404221 | xxx       | 10002:0        | xxx | Query       |   28939 | Waiting for global read lock                                          | UPDATE USERS A SET ....... 



尽量将长时间的DDL转变为DML语句,执行失败的DDL及时kill掉。没空了...稍后补充


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值