MySQL:简单记录一下Waiting for commit lock

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: Waiting for global read lock:由于flush table with read lock调用函数lock_global_read_lock导致DML操作堵塞。Waiting for commit lock :由于flush table with read lock 调...
  • Waiting for global read lock:由于flush table with read lock调用函数lock_global_read_lock导致DML操作堵塞。
  • Waiting for commit lock :由于flush table with read lock 调用函数make_global_read_lock_block_commit导致事务不能提交

现象

堵塞COMMIT和DML

mysql> show processlist;
+----+-----------------+-----------+---------+---------+------+------------------------------+----------------------------+-----------+---------------+
| Id | User            | Host      | db      | Command | Time | State                        | Info                       | Rows_sent | Rows_examined |
+----+-----------------+-----------+---------+---------+------+------------------------------+----------------------------+-----------+---------------+
|  1 | event_scheduler | localhost | NULL    | Daemon  |  268 | Waiting on empty queue       | NULL                       |         0 |             0 |
|  5 | root            | localhost | NULL    | Query   |    0 | starting                     | show processlist           |         0 |             0 |
|  6 | root            | localhost | testmts | Query   |   61 | Waiting for commit lock      | commit                     |         0 |             0 |
|  7 | root            | localhost | testmts | Query   |    6 | Waiting for global read lock | delete from testcp limit 1 |         0 |             0 |
+----+-----------------+-----------+---------+---------+------+------------------------------+----------------------------+-----------+---------------+

相关栈帧

Waiting for commit lock
#0  0x00007ffff7bd3a5e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x000000000192027b in native_cond_timedwait (cond=0x7ffee0000d08, mutex=0x7ffee0000cc0, abstime=0x7fffec5ec950)
    at /mysqldata/percona-server-locks-detail-5.7.22/include/thr_cond.h:129
#2  0x00000000019205ea in safe_cond_timedwait (cond=0x7ffee0000d08, mp=0x7ffee0000c98, abstime=0x7fffec5ec950, 
    file=0x204cdd0 "/mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc", line=1899) at /mysqldata/percona-server-locks-detail-5.7.22/mysys/thr_cond.c:88
#3  0x00000000014b9f21 in my_cond_timedwait (cond=0x7ffee0000d08, mp=0x7ffee0000c98, abstime=0x7fffec5ec950, 
    file=0x204cdd0 "/mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc", line=1899) at /mysqldata/percona-server-locks-detail-5.7.22/include/thr_cond.h:180
#4  0x00000000014ba484 in inline_mysql_cond_timedwait (that=0x7ffee0000d08, mutex=0x7ffee0000c98, abstime=0x7fffec5ec950, 
    src_file=0x204cdd0 "/mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc", src_line=1899)
    at /mysqldata/percona-server-locks-detail-5.7.22/include/mysql/psi/mysql_thread.h:1229
#5  0x00000000014bb702 in MDL_wait::timed_wait (this=0x7ffee0000c98, owner=0x7ffee0000c00, abs_timeout=0x7fffec5ec950, set_status_on_timeout=true, 
    wait_state_name=0x2d93240) at /mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc:1899
#6  0x00000000014bd7ac in MDL_context::acquire_lock (this=0x7ffee0000c98, mdl_request=0x7fffec5ec9c0, lock_wait_timeout=31536000)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc:3746
#7  0x0000000000f7ffe4 in ha_commit_trans (thd=0x7ffee0000c00, all=true, ignore_global_read_lock=false)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/handler.cc:1795
#8  0x00000000016dcd2f in trans_commit (thd=0x7ffee0000c00) at /mysqldata/percona-server-locks-detail-5.7.22/sql/transaction.cc:239
#9  0x00000000015cf466 in mysql_execute_command (thd=0x7ffee0000c00, first_level=true) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:4526
#10 0x00000000015d2fde in mysql_parse (thd=0x7ffee0000c00, parser_state=0x7fffec5ee600) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
#11 0x00000000015c6b72 in dispatch_command (thd=0x7ffee0000c00, com_data=0x7fffec5eed70, command=COM_QUERY)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
#12 0x00000000015c58ff in do_command (thd=0x7ffee0000c00) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
#13 0x000000000170e578 in handle_connection (arg=0x67bf490) at /mysqldata/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
#14 0x0000000001945538 in pfs_spawn_thread (arg=0x66ff4f0) at /mysqldata/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
#15 0x00007ffff7bcfaa1 in start_thread () from /lib64/libpthread.so.0
#16 0x00007ffff6b37c4d in clone () from /lib64/libc.so.6
Waiting for global read lock
#0  0x00007ffff7bd3a5e in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x000000000192027b in native_cond_timedwait (cond=0x7ffee4000c98, mutex=0x7ffee4000c50, abstime=0x7fffec58a0e0)
    at /mysqldata/percona-server-locks-detail-5.7.22/include/thr_cond.h:129
#2  0x00000000019205ea in safe_cond_timedwait (cond=0x7ffee4000c98, mp=0x7ffee4000c28, abstime=0x7fffec58a0e0, 
    file=0x204cdd0 "/mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc", line=1899) at /mysqldata/percona-server-locks-detail-5.7.22/mysys/thr_cond.c:88
#3  0x00000000014b9f21 in my_cond_timedwait (cond=0x7ffee4000c98, mp=0x7ffee4000c28, abstime=0x7fffec58a0e0, 
    file=0x204cdd0 "/mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc", line=1899) at /mysqldata/percona-server-locks-detail-5.7.22/include/thr_cond.h:180
#4  0x00000000014ba484 in inline_mysql_cond_timedwait (that=0x7ffee4000c98, mutex=0x7ffee4000c28, abstime=0x7fffec58a0e0, 
    src_file=0x204cdd0 "/mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc", src_line=1899)
    at /mysqldata/percona-server-locks-detail-5.7.22/include/mysql/psi/mysql_thread.h:1229
#5  0x00000000014bb702 in MDL_wait::timed_wait (this=0x7ffee4000c28, owner=0x7ffee4000b90, abs_timeout=0x7fffec58a0e0, set_status_on_timeout=true, 
    wait_state_name=0x2d93180) at /mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc:1899
#6  0x00000000014bd7ac in MDL_context::acquire_lock (this=0x7ffee4000c28, mdl_request=0x7fffec58a160, lock_wait_timeout=31536000)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/mdl.cc:3746
#7  0x000000000153bed8 in open_table (thd=0x7ffee4000b90, table_list=0x7ffee40066e0, ot_ctx=0x7fffec58a5a0)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_base.cc:3233
#8  0x000000000153f904 in open_and_process_table (thd=0x7ffee4000b90, lex=0x7ffee40031c0, tables=0x7ffee40066e0, counter=0x7ffee4003280, flags=0, 
    prelocking_strategy=0x7fffec58a6d0, has_prelocking_list=false, ot_ctx=0x7fffec58a5a0) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_base.cc:5213
#9  0x0000000001540a58 in open_tables (thd=0x7ffee4000b90, start=0x7fffec58a690, counter=0x7ffee4003280, flags=0, prelocking_strategy=0x7fffec58a6d0)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_base.cc:5831
#10 0x0000000001541e93 in open_tables_for_query (thd=0x7ffee4000b90, tables=0x7ffee40066e0, flags=0)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_base.cc:6606
#11 0x00000000017f2b53 in Sql_cmd_delete::mysql_delete (this=0x7ffee4006c80, thd=0x7ffee4000b90, limit=1)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:76
#12 0x00000000017f7098 in Sql_cmd_delete::execute (this=0x7ffee4006c80, thd=0x7ffee4000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_delete.cc:1386
#13 0x00000000015cc801 in mysql_execute_command (thd=0x7ffee4000b90, first_level=true) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:3756
#14 0x00000000015d2fde in mysql_parse (thd=0x7ffee4000b90, parser_state=0x7fffec58c600) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:5901
#15 0x00000000015c6b72 in dispatch_command (thd=0x7ffee4000b90, com_data=0x7fffec58cd70, command=COM_QUERY)
    at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1490
#16 0x00000000015c58ff in do_command (thd=0x7ffee4000b90) at /mysqldata/percona-server-locks-detail-5.7.22/sql/sql_parse.cc:1021
#17 0x000000000170e578 in handle_connection (arg=0x67182c0) at /mysqldata/percona-server-locks-detail-5.7.22/sql/conn_handler/connection_handler_per_thread.cc:312
#18 0x0000000001945538 in pfs_spawn_thread (arg=0x671aca0) at /mysqldata/percona-server-locks-detail-5.7.22/storage/perfschema/pfs.cc:2190
#19 0x00007ffff7bcfaa1 in start_thread () from /lib64/libpthread.so.0
#20 0x00007ffff6b37c4d in clone () from /lib64/libc.so.6
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
9月前
|
SQL 关系型数据库 MySQL
Mysql Lock Wait
Mysql Lock Wait
147 0
|
5月前
|
关系型数据库 MySQL 数据库
MySQL报错:Lock wait timeout exceeded; try restarting transaction
MySQL报错:Lock wait timeout exceeded; try restarting transaction
|
5月前
|
SQL 关系型数据库 MySQL
MySQL报错:1205 Lock wait timeout exceeded; try restarting transaction处理
MySQL报错:1205 Lock wait timeout exceeded; try restarting transaction处理
|
6月前
|
SQL 关系型数据库 MySQL
【MySQL异常】MySQL事务锁问题----lock wait timeout exceeded; try restarting transaction
【MySQL异常】MySQL事务锁问题----lock wait timeout exceeded; try restarting transaction
49 0
|
9月前
|
SQL 关系型数据库 MySQL
Mysql 异常:Lock wait timeout exceeded; try restarting transaction的解决办法
Mysql 异常:Lock wait timeout exceeded; try restarting transaction的解决办法
103 0
|
9月前
|
SQL 关系型数据库 MySQL
mysql Lock wait timeout exceeded; try restarting transaction解决方案
在测试程序时,打的断点怎么都跳不进去,console一直报 “Lock wait timeout exceeded; try restarting transaction”
108 0
|
11月前
|
SQL 存储 缓存
|
12月前
|
存储 SQL 设计模式
【MySQL技术内幕】7.2.3-purge和group commit
【MySQL技术内幕】7.2.3-purge和group commit
90 0
|
关系型数据库 MySQL 数据库
MySQL命令记录
MySQL编码 1.查看数据库编码格式 show create database <数据库名>; 2.查看数据表的编码格式 show create table <表名>; 3.创建数据库时指定数据库的字符集 create database <数据库名> character set utf8; 4.创建数据表时指定数据表的编码格式 create table tb_books( name varchar(45) not null, price double not null, bookCount int not null,
|
关系型数据库 MySQL 数据库
记录学习MySql常用函数
记录学习MySql常用函数
166 16