purge
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的更多相关文章
- UNABLE TO PURGE A RECORD(二)
上一篇文章说明了bug出现的原因和原理分析,要修复bug似乎已经水到渠成了,但远没有这么简单,只因为“并发”.要修复问题,首先要做的第一件事情是稳定的复现问题.由于数据库系统是一个并发系统,并且这个b ...
- Bug #19528825 "UNABLE TO PURGE A RECORD"
概述: 在生产环境中,当开启insert buffer时(参数innodb_change_buffering=all),部分实例偶尔会出现“UNABLE TO PURGE A RECORD”错误.这个 ...
- purge mysql自带命令清除binlog
#!/bin/bash DATAUSER=root DATAPASS=shiyiwen DAY=$1 if [ ! $# == 1 ];then echo -e "\033[32m USAG ...
- 一个purge参数引发的惨案——从线上hbase数据被删事故说起
在写这篇blog前,我的心情久久不能平静,虽然明白运维工作如履薄冰,但没有料到这么一个细小的疏漏会带来如此严重的灾难.这是一起其他公司误用puppet参数引发的事故,而且这个参数我也曾被“坑过”. ...
- 什么是purge操作
要明白什么清空(purge)操作,你得明白什么是事务的多版本控制,即MVCC(multi-version concurrency control).Innodb为了实现MVCC, 需要在表空间内保存老 ...
- DROP TABLE ** CASCADE CONSTRAINTS PURGE删除表的时候级联删除从表外键
1.关于 cascade constraints 假设A为主表(既含有某一主键的表),B为从表(即引用了A的主键作为外键). 则当删除A表时,如不特殊说明,则 drop table A 系统会出现错误 ...
- Using dbms_shared_pool.purge to remove a single task from the library cache
我们都知道可是使用 alter system flush shared_pool 来清除shared pool 信息,当时不能指定清除某个对象.因为在系统繁忙的时侯 使用 alter system f ...
- 手动purge优化器的统计信息与AWR快照,减少对sysaux表空间的占用
1.运行以下脚本,计算当前优化器统计信息和AWR快照表占用sysaux的空间 SQL> conn / as sysdba SQL> @?/rdbms/admin/awrinfo.sql 2 ...
- purgeIdleCellConnections: found one to purge conn = 0x1e09f7d0
purgeIdleCellConnections: found one to purge conn = 0x1e09f7d0 你在iOS6下使用3G网络时可能会遇到这条log,不用紧张,这只是苹果的工 ...
- 死锁相关 变量 与 PURGE 线程停止
http://www.tuicool.com/articles/NzAFZn https://github.com/percona/percona-server/pull/83/commits/091 ...
随机推荐
- 类的大小——sizeof 的研究
类的大小——sizeof 的研究(1) 先看一个空的类占多少空间? class Base { public: Base(); ~Base(); }; 注意到我这里显示声明了构造跟析构,但是sizeof ...
- HLS -- m3u8档案格式解析
1. Playlist file 一个M3U的 Playlist 就是一个由多个独立行组成的文本文件,每行由回车/换行区分.每一行可以是一个URI.空白行或 是以”#“号开头的字符串,并且空格只能存在 ...
- Python:映像、集合
一.字典 字典(dictionary)是Python中唯一的“映射”类型,映射这个概念在高中就学过:一个函数f将键(key, 定义域)映射到值(value, 值域).这样的函数在字典中可以称为哈希(H ...
- [cocos2d-js]按钮整合成大图后打APK后不显示
网页版本都能正常显示碎图和整合成大图的 手机版本不正常 var btnKick = cc.MenuItemImage.create( "#btn_kick.png", " ...
- Delphi IOS环境安装
RAD Delphi XE/10 Seattle 安装IOS.OSX环境安装,IOS模拟器,MAC X 真机可以调试 http://community.embarcadero.com/blogs/en ...
- HD2144Calculate S(n)
Problem Description Calculate S(n). S(n)=13+23 +33 +......+n3 . Input Each line will contain one int ...
- Type Encoding
[Type Encodings] The compiler encodes the return and argument types for each method in a character s ...
- oracle学习 四(持续更新中)无法为表空间 MAXDATA 中的段创建 INITIAL 区
解决建立表的时候出现的 ORA-01658: 无法为表空间 MAXDATA 中的段创建 INITIAL 区 出现这个问题是因为表空间的大小不足,可以给他扩容这样的话也会多出来一个数据文件.具体写法如下 ...
- C#与C++对应的类型
//c++:HANDLE(void *) ---- c#:System.IntPtr //c++:Byte(unsigned char) ---- c ...
- C# 特性详解(上)
特性(attribute)是被指定给某一声明的一则附加的声明性信息. 元数据,就是C#中封装的一些类,无法修改.类成员的特性被称为元数据中的注释. 1.什么是特性 1)属性与特性的区别 属性 ...