RR级别

mysql V5.6 debug

set global innodb_purge_stop_now=1;

测试1

会话1:


mysql> create table a( a int primary key,b varchar(30));
Query OK, 0 rows affected (0.04 sec) mysql> insert into a values(1,"a");
Query OK, 1 row affected (0.17 sec) mysql> insert into a values(2,"b");
Query OK, 1 row affected (0.18 sec) mysql> insert into a values(3,"c");
Query OK, 1 row affected (0.01 sec) mysql> insert into a values(4,"d");
Query OK, 1 row affected (0.17 sec) mysql> delete from a where a=3;
Query OK, 1 row affected (0.01 sec) mysql> select * from a;
+---+------+
| a | b |
+---+------+
| 1 | a |
| 2 | b |
| 4 | d |
+---+------+
3 rows in set (0.00 sec) mysql> begin;
Query OK, 0 rows affected (0.17 sec) mysql> select * from a where a<=3 for update;
+---+------+
| a | b |
+---+------+
| 1 | a |
| 2 | b |
+---+------+
2 rows in set (0.01 sec)

会话2:

---TRANSACTION 107908, ACTIVE 65 sec
2 lock struct(s), heap size 376, 4 row lock(s)
MySQL thread id 5, OS thread handle 0x2ab31a1d2940, query id 136 localhost root cleaning up
Trx read view will not see trx with id >= 107909, sees < 107909
TABLE LOCK table `test`.`a` trx id 107908 lock mode IX
RECORD LOCKS space id 240 page no 3 n bits 72 index `PRIMARY` of table `test`.`a` trx id 107908 lock_mode X
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000001; asc ;;
1: len 6; hex 00000001a575; asc u;;
2: len 7; hex c6000001cd0110; asc ;;
3: len 1; hex 61; asc a;; Record lock, heap no 3 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000002; asc ;;
1: len 6; hex 00000001a576; asc v;;
2: len 7; hex c7000002310110; asc 1 ;;
3: len 1; hex 62; asc b;; Record lock, heap no 4 PHYSICAL RECORD: n_fields 4; compact format; info bits 32
0: len 4; hex 80000003; asc ;;
1: len 6; hex 00000001a581; asc ;;
2: len 7; hex 4e000001f618a5; asc N ;;
3: len 1; hex 63; asc c;; Record lock, heap no 5 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000004; asc ;;
1: len 6; hex 00000001a57c; asc |;;
2: len 7; hex cb0000016b0110; asc k ;;
3: len 1; hex 64; asc d;;

测试2:

会话1:

mysql> create table a( a int primary key,b varchar(30));
Query OK, 0 rows affected (0.20 sec) mysql> insert into a values(1,"a");
Query OK, 1 row affected (0.02 sec) mysql> insert into a values(2,"b");
Query OK, 1 row affected (0.18 sec) mysql> insert into a values(3,"c");
Query OK, 1 row affected (0.17 sec) mysql> insert into a values(4,"d");
Query OK, 1 row affected (0.19 sec) mysql> begin;
Query OK, 0 rows affected (0.00 sec) mysql> delete from a where a=3;
Query OK, 1 row affected (0.01 sec)

会话2:

mysql> begin;
Query OK, 0 rows affected (0.00 sec) mysql> insert into a select 3,"c";
等待

会话3:

---TRANSACTION 107978, ACTIVE 30 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 376, 1 row lock(s)
MySQL thread id 8, OS thread handle 0x2ab31a190940, query id 187 localhost root executing
insert into a select 3,"c"
------- TRX HAS BEEN WAITING 30 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 242 page no 3 n bits 72 index `PRIMARY` of table `test`.`a` trx id 107978 lock mode S locks rec but not gap waiting
Record lock, heap no 4 PHYSICAL RECORD: n_fields 4; compact format; info bits 32
0: len 4; hex 80000003; asc ;;
1: len 6; hex 00000001a5c8; asc ;;
2: len 7; hex 780000018d0d16; asc x ;;
3: len 1; hex 63; asc c;; ------------------
TABLE LOCK table `test`.`a` trx id 107978 lock mode IX
RECORD LOCKS space id 242 page no 3 n bits 72 index `PRIMARY` of table `test`.`a` trx id 107978 lock mode S locks rec but not gap waiting
Record lock, heap no 4 PHYSICAL RECORD: n_fields 4; compact format; info bits 32
0: len 4; hex 80000003; asc ;;
1: len 6; hex 00000001a5c8; asc ;;
2: len 7; hex 780000018d0d16; asc x ;;
3: len 1; hex 63; asc c;; ---TRANSACTION 107976, ACTIVE 79 sec
2 lock struct(s), heap size 376, 1 row lock(s), undo log entries 1
MySQL thread id 5, OS thread handle 0x2ab31a1d2940, query id 184 localhost root cleaning up
TABLE LOCK table `test`.`a` trx id 107976 lock mode IX
RECORD LOCKS space id 242 page no 3 n bits 72 index `PRIMARY` of table `test`.`a` trx id 107976 lock_mode X locks rec but not gap
Record lock, heap no 4 PHYSICAL RECORD: n_fields 4; compact format; info bits 32 //该记录已经删除,但未提交
0: len 4; hex 80000003; asc ;;
1: len 6; hex 00000001a5c8; asc ;;
2: len 7; hex 780000018d0d16; asc x ;;
3: len 1; hex 63; asc c;;

插入一个记录:对该记录加 lock mode S locks rec
删除一条记录:对该记录加lock_mode X locks rec

测试3:

set global innodb_purge_stop_now=1;

mysql> select * from t;
+---+
| a |
+---+
| 1 |
| 3 |
+---+
2 rows in set (0.01 sec) mysql> show create table t; CREATE TABLE `t` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk
mysql> delete from t where a=2;
Query OK, 1 row affected (0.00 sec)
mysql> begin;
Query OK, 0 rows affected (0.01 sec) mysql> select * from t where a=2 for update;
Empty set (0.00 sec)
---TRANSACTION 109372, ACTIVE 16 sec
2 lock struct(s), heap size 376, 1 row lock(s)
MySQL thread id 1, OS thread handle 0x2b2a48081940, query id 37 localhost root cleaning up
TABLE LOCK table `test`.`t` trx id 109372 lock mode IX
RECORD LOCKS space id 248 page no 3 n bits 72 index `PRIMARY` of table `test`.`t` trx id 109372 lock_mode X locks rec but not gap
Record lock, heap no 3 PHYSICAL RECORD: n_fields 3; compact format; info bits 32 //已经删掉了,加了 记录锁
0: len 4; hex 80000002; asc ;;
1: len 6; hex 00000001ab36; asc 6;;
2: len 7; hex 25000001571dd2; asc % W ;;
mysql> rollback;
Query OK, 0 rows affected (0.00 sec) mysql> insert into t select 2;
Query OK, 1 row affected (0.19 sec)
Records: 1 Duplicates: 0 Warnings: 0 mysql> begin;
Query OK, 0 rows affected (0.01 sec) mysql> select * from t where a<3 for update;
+---+
| a |
+---+
| 1 |
| 2 |
+---+
2 rows in set (0.01 sec)
---TRANSACTION 109375, ACTIVE 5 sec
2 lock struct(s), heap size 376, 4 row lock(s)
MySQL thread id 1, OS thread handle 0x2b2a48081940, query id 44 localhost root cleaning up
TABLE LOCK table `test`.`t` trx id 109375 lock mode IX
RECORD LOCKS space id 248 page no 3 n bits 72 index `PRIMARY` of table `test`.`t` trx id 109375 lock_mode X
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;; 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 00000001ab2f; asc /;;
2: len 7; hex a0000001ea0110; asc ;; Record lock, heap no 3 PHYSICAL RECORD: n_fields 3; compact format; info bits 0 原来的 2已丢失了
0: len 4; hex 80000002; asc ;;
1: len 6; hex 00000001ab3d; asc =;;
2: len 7; hex 29000001ae186e; asc ) n;; Record lock, heap no 4 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
0: len 4; hex 80000003; asc ;;
1: len 6; hex 00000001ab35; asc 5;;
2: len 7; hex a4000001ac0110; asc ;;

purge的更多相关文章

  1. UNABLE TO PURGE A RECORD(二)

    上一篇文章说明了bug出现的原因和原理分析,要修复bug似乎已经水到渠成了,但远没有这么简单,只因为“并发”.要修复问题,首先要做的第一件事情是稳定的复现问题.由于数据库系统是一个并发系统,并且这个b ...

  2. Bug #19528825 "UNABLE TO PURGE A RECORD"

    概述: 在生产环境中,当开启insert buffer时(参数innodb_change_buffering=all),部分实例偶尔会出现“UNABLE TO PURGE A RECORD”错误.这个 ...

  3. purge mysql自带命令清除binlog

    #!/bin/bash DATAUSER=root DATAPASS=shiyiwen DAY=$1 if [ ! $# == 1 ];then echo -e "\033[32m USAG ...

  4. 一个purge参数引发的惨案——从线上hbase数据被删事故说起

    在写这篇blog前,我的心情久久不能平静,虽然明白运维工作如履薄冰,但没有料到这么一个细小的疏漏会带来如此严重的灾难.这是一起其他公司误用puppet参数引发的事故,而且这个参数我也曾被“坑过”.   ...

  5. 什么是purge操作

    要明白什么清空(purge)操作,你得明白什么是事务的多版本控制,即MVCC(multi-version concurrency control).Innodb为了实现MVCC, 需要在表空间内保存老 ...

  6. DROP TABLE ** CASCADE CONSTRAINTS PURGE删除表的时候级联删除从表外键

    1.关于 cascade constraints 假设A为主表(既含有某一主键的表),B为从表(即引用了A的主键作为外键). 则当删除A表时,如不特殊说明,则 drop table A 系统会出现错误 ...

  7. Using dbms_shared_pool.purge to remove a single task from the library cache

    我们都知道可是使用 alter system flush shared_pool 来清除shared pool 信息,当时不能指定清除某个对象.因为在系统繁忙的时侯 使用 alter system f ...

  8. 手动purge优化器的统计信息与AWR快照,减少对sysaux表空间的占用

    1.运行以下脚本,计算当前优化器统计信息和AWR快照表占用sysaux的空间 SQL> conn / as sysdba SQL> @?/rdbms/admin/awrinfo.sql 2 ...

  9. purgeIdleCellConnections: found one to purge conn = 0x1e09f7d0

    purgeIdleCellConnections: found one to purge conn = 0x1e09f7d0 你在iOS6下使用3G网络时可能会遇到这条log,不用紧张,这只是苹果的工 ...

  10. 死锁相关 变量 与 PURGE 线程停止

    http://www.tuicool.com/articles/NzAFZn https://github.com/percona/percona-server/pull/83/commits/091 ...

随机推荐

  1. 干掉cmd:windows下使用linux命令行

    对于喜欢用命令行的朋友们,在windows下面使用cmd窗口是不是很不爽?复制不方便?不能随意放大缩小?如果需要多个控制台要多个窗口?....各种不爽 一.基础工具 如果你也不爽,那就对了,所以给大家 ...

  2. 使用arm开发板搭建无线mesh网络(一)

    由于项目的需要,老板让我使用arm开发板(友善之臂的tiny6410)搭建无线mesh网络.一般而言,无线自组织网络的网络设备都是由用户的终端设备来充当,这些终端设备既要处理用户的应用数据,比如娱乐, ...

  3. 第三百零八至三百二十天 how can I 坚持

    十三天..2月4号至2月16号,好快,假期还没开始就结束了.一一回忆下. 2月4号,腊月二十六,最后一天上班,没多大事,好像是玩了一天,东月回家,貌似路上好折腾,晚上D401,和她聊了一路,也聊了好多 ...

  4. 我的第一个CUDA程序

    最近在学习CUDA框架,折腾了一个多月终于把CUDA安装完毕,现在终于跑通了自己的一个CUDA的Hello world程序,值得欣喜~ 首先,关于CUDA的初始化,代码和解释如下,这部分主要参考GXW ...

  5. spring的annotation-driven配置事务管理器详解

    http://blog.sina.com.cn/s/blog_8f61307b0100ynfb.html ——————————————————————————————————————————————— ...

  6. G450 CPU 升级

    T系列是正常功耗的CPU,功耗35W,发热量大些, P系列是低功耗的U,功耗25W,发热量小些. P8700的性能比T6600高15%左右,不过平常应用感觉不是很明显. p8800cpu P8600 ...

  7. IOC知识

    1.两个基本概念 IOC(Inversion of Control ):反转控制,即将控制权反转出去. DI(Dependency Injection):依赖注入,根据依赖关系进行注入. DI是实现I ...

  8. Add mappings to an Elasticsearch index in realtime

    Changing mapping on existing index is not an easy task. You may find the reason and possible solutio ...

  9. iOS的几种定时器

    //gcd的定时器timer必须先保存为一个属性或者成员变量 @property (nonatomic , assign) dispatch_source_t timer; //第一种 每一秒执行一次 ...

  10. socket编写简单回显server

    socket在公司代码中应用比较广,比如接口调用的IPCRPC机制,经常看到这样的代码,但是一直也没有动手写过. 在某个比较大的进程中创建一个子进程,由于父子进程复制会浪费内存,可以将创建进程的命令通 ...