MySQLInnodb怎么让MDLLOCK和ROWLOCK记录到errlog
本篇内容主要讲解“MySQL Innodb怎么让MDL LOCK和ROW LOCK记录到errlog”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL Innodb怎么让MDL LOCK和ROW LOCK记录到errlog”吧!
成都创新互联主营台江网站建设的网络公司,主营网站建设方案,app软件定制开发,台江h5小程序设计搭建,台江网站营销推广欢迎台江等地区企业咨询
一、新加入的参数和保留的参数
mysql> show variables like '%gaopeng%'; +--------------------------------+-------+| Variable_name | Value | +--------------------------------+-------+ | gaopeng_mdl_detail | OFF || innodb_gaopeng_row_lock_detail | ON | +--------------------------------+-------+
gaopeng_mdl_detail:默认OFF,可以设置ON 用于打印MDL LOCK获取、等待、升级、降级、释放日志到errlog(GOBAL),并且可以在show engine中获取
innodb_gaopeng_row_lock_detail:默认OFF,可以设置为ON,用于打印innodb ROW LOCK获取日志、等待日志、隐含锁转换日志等到errlog,并且可以在show engine中获取详细锁链表信息(注意
没有行的详细信息需要开启innodb_show_verbose_locks) 到errlog(GLOBAL)。但是没有做表级印象锁输出。保留原有参数
innodb_show_verbose_locks:默认为0,设置为1,可以在show engine中获取锁定的行详细信息。
二、测试概要
MySQL MDL LOCK
也就是如果要MDL LOCK测试设置如下:
set global gaopeng_mdl_detail=1;
重新登陆后每次获取MDL LOCK信息会得到日志,下面是一个select语句获取MDL LOCK和释放的日志:
2018-09-01T20:32:07.090351+08:00 11 [Note] [Call Acquire_lock] THIS MDL LOCK acquire [OK]: 2018-09-01T20:32:07.090503+08:00 11 [Note] (>MDL PRINT) |Thread id is 11|Current_state: Opening tables| 2018-09-01T20:32:07.090542+08:00 11 [Note] (->MDL PRINT) DB_name is:test 2018-09-01T20:32:07.090571+08:00 11 [Note] (-->MDL PRINT) OBJ_name is:kkkpk 2018-09-01T20:32:07.090595+08:00 11 [Note] (--->MDL PRINT) Namespace is:TABLE 2018-09-01T20:32:07.090608+08:00 11 [Note] (---->MDL PRINT) Fast path is:(Y) 2018-09-01T20:32:07.090621+08:00 11 [Note] (----->MDL PRINT) Mdl type is:MDL_SHARED_READ(SR) 2018-09-01T20:32:07.090635+08:00 11 [Note] (------->MDL PRINT) Mdl status is:EMPTY 2018-09-01T20:32:07.091077+08:00 11 [Note] [Call release_lock] this MDL LOCK will [RELEASE]: 2018-09-01T20:32:07.091168+08:00 11 [Note] (>MDL PRINT) |Thread id is 11|Current_state: closing tables| 2018-09-01T20:32:07.091197+08:00 11 [Note] (->MDL PRINT) DB_name is:test 2018-09-01T20:32:07.091210+08:00 11 [Note] (-->MDL PRINT) OBJ_name is:kkkpk 2018-09-01T20:32:07.091241+08:00 11 [Note] (--->MDL PRINT) Namespace is:TABLE 2018-09-01T20:32:07.091254+08:00 11 [Note] (---->MDL PRINT) Fast path is:(Y) 2018-09-01T20:32:07.091267+08:00 11 [Note] (----->MDL PRINT) Mdl type is:MDL_SHARED_READ(SR) 2018-09-01T20:32:07.091280+08:00 11 [Note] (------->MDL PRINT) Mdl status is:EMPTY
Innodb ROW LOCK
如果需要INNODB ROW LOCK加锁测试可以设置如下:
set global innodb_gaopeng_row_lock_detail=1;
set innodb_show_verbose_locks=1;
重新登陆,下面是一个insert唯一性检查锁定的日志:
2018-09-01T20:26:08.809304+08:00 10 [Note] InnoDB: This TRX help other TRX convert impl lock to expl lock!!!insert often use impl lock!!!! 2018-09-01T20:26:08.809422+08:00 10 [Note] InnoDB: Other TRX: 2018-09-01T20:26:08.809477+08:00 10 [Note] InnoDB: TRX ID:(1294) table:test/kkkpk index:PRIMARY space_id: 28 page_id:3 heap_no:2 row lock mode:LOCK_X|LOCK_NOT_GAP| PHYSICAL RECORD: n_fields 3; compact format; info bits 0 0: len 4; hex 80000001; asc ;; 1: len 6; hex 00000000050e; asc ;; 2: len 7; hex ae0000001e0110; asc ;; 2018-09-01T20:26:08.809824+08:00 10 [Note] InnoDB: This TRX: 2018-09-01T20:26:08.809851+08:00 10 [Note] InnoDB: TRX ID:(1295) table:test/kkkpk index:PRIMARY space_id: 28 page_id:3 heap_no:2 row lock mode:LOCK_S|LOCK_NOT_GAP| PHYSICAL RECORD: n_fields 3; compact format; info bits 0 0: len 4; hex 80000001; asc ;; 1: len 6; hex 00000000050e; asc ;; 2: len 7; hex ae0000001e0110; asc ;; 2018-09-01T20:26:08.810401+08:00 10 [Note] InnoDB: Trx(1295) is blocked!!!!!
show engine 也会得到如下记录:
---TRANSACTION 1295, ACTIVE 101 sec inserting mysql tables in use 1, locked 1LOCK WAIT 2 lock struct(s), heap size 1136, 1 row lock(s) MySQL thread id 10, OS thread handle 139670301562624, query id 55 localhost root update insert into kkkpk values(1) ------- TRX HAS BEEN WAITING 101 SEC FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 28 page no 3 n bits 72 index PRIMARY of table `test`.`kkkpk` trx id 1295 lock mode S(LOCK_S) locks rec but not gap(LOCK_REC_NOT_GAP) waiting(LOCK_WAIT) Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 0 0: len 4; hex 80000001; asc ;; 1: len 6; hex 00000000050e; asc ;; 2: len 7; hex ae0000001e0110; asc ;; ------------------ TABLE LOCK table `test`.`kkkpk` trx id 1295 lock mode IX RECORD LOCKS space id 28 page no 3 n bits 72 index PRIMARY of table `test`.`kkkpk` trx id 1295 lock mode S(LOCK_S) locks rec but not gap(LOCK_REC_NOT_GAP) waiting(LOCK_WAIT) Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 0 0: len 4; hex 80000001; asc ;; 1: len 6; hex 00000000050e; asc ;; 2: len 7; hex ae0000001e0110; asc ;; ---TRANSACTION 1294, ACTIVE 132 sec2 lock struct(s), heap size 1136, 1 row lock(s), undo log entries 1MySQL thread id 9, OS thread handle 139670301828864, query id 56 localhost root starting show engine innodb status TABLE LOCK table `test`.`kkkpk` trx id 1294 lock mode IX RECORD LOCKS space id 28 page no 3 n bits 72 index PRIMARY of table `test`.`kkkpk` trx id 1294 lock_mode X(LOCK_X) locks rec but not gap(LOCK_REC_NOT_GAP) Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 0 0: len 4; hex 80000001; asc ;; 1: len 6; hex 00000000050e; asc ;; 2: len 7; hex ae0000001e0110; asc ;;
到此,相信大家对“MySQL Innodb怎么让MDL LOCK和ROW LOCK记录到errlog”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
当前标题:MySQLInnodb怎么让MDLLOCK和ROWLOCK记录到errlog
URL标题:http://azwzsj.com/article/jpodec.html