+------+------+------+------+ orignal | 10 | 20 | 30 | 40 | unique +------+------+------+------+ delete 20 +------+------+------+------+ | 10 | 20* | 30 | 40 | (20 : delete-mark) and commit +------+^----^+------+------+ | | non happen | +--insert new 20 | Purge # 自增主键图中没有给出
[root@MyServer ~]> mysqld-debug --version mysqld-debug Ver 5.7.11-debug for linux-glibc2.5 on x86_64 (MySQL Community Server - Debug (GPL)) [root@MyServer ~]> mysqld-debug --datadir=/data/mysql_data/5.7.11/ & [1] 1493 [root@MyServer ~]> netstat -tunlp | grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1493/mysqld-debug -- -- 终端会话1 mysql> create table test_purge(a int auto_increment primary key, b int , unique key(b)); Query OK, 0 rows affected (0.20 sec) mysql> insert into test_purge(b) values (10),(20),(30),(40); Query OK, 4 rows affected (0.05 sec) mysql> commit; -- autocommit=0 in my.cnf Query OK, 0 rows affected (0.03 sec) mysql> set global innodb_purge_stop_now=1; -- show这个变量,结果还是off,这个不用管,purge线程已经停止了 Query OK, 0 rows affected (0.00 sec) mysql> begin; mysql> delete from test_purge where b=20; Query OK, 1 row affected (0.00 sec) mysql> commit; Query OK, 0 rows affected (0.02 sec) -- 终端会话2 mysql> select * from test_purge; +---+------+ | a | b | -- 20的那条记录已经删除,但是还没有被purge(purge线程停止) | 1 | 10 | | 3 | 30 | | 4 | 40 | 3 rows in set (0.00 sec) mysql> insert into test_purge(b) values(20); Query OK, 1 row affected (0.04 sec) -- 终端会话3 mysql> show engine innodb status\G -- ----------------省略其他输出---------------- ---TRANSACTION 9497, ACTIVE 19 sec 3 lock struct(s), heap size 1160, 3 row lock(s), undo log entries 1 MySQL thread id 3, OS thread handle 139922002294528, query id 26 localhost root cleaning up TABLE LOCK table `burn_test`.`test_purge` trx id 9497 lock mode IX RECORD LOCKS space id 47 page no 4 n bits 72 index b of table `burn_test`.`test_purge` trx id 9497 lock mode S -- S lock (with gap) Record lock, heap no 3 PHYSICAL RECORD: n_fields 2; compact format; info bits 32 -- heap no=3表示是第二个插入的记录20 -- 且info bits为32,表示记录被标记删除了 0: len 4; hex 80000014; asc ;; -- 记录为20 1: len 4; hex 80000002; asc ;; -- 对应的主键为2 Record lock, heap no 4 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 -- heap no=4表示的是20的下一个记录30 -- 且该记录上也有S lock 0: len 4; hex 8000001e; asc ;; 1: len 4; hex 80000003; asc ;; RECORD LOCKS space id 47 page no 4 n bits 72 index b of table `burn_test`.`test_purge` trx id 9497 lock mode S locks gap before rec Record lock, heap no 6 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 -- heap no=6为新插入的记录20,从隐式锁提升为显示锁 0: len 4; hex 80000014; asc ;; 1: len 4; hex 80000005; asc ;;
mysql> insert into test_purge(b) values(25); ERROR 1205 (HY000): Unknown error 1205 -- 等待了一段时间后,超时 ---TRANSACTION 9508, ACTIVE 3 sec inserting mysql tables in use 1, locked 1 LOCK WAIT 2 lock struct(s), heap size 1160, 1 row lock(s), undo log entries 1 MySQL thread id 5, OS thread handle 139922002560768, query id 46 localhost root update insert into test_purge(b) values(25) -- 插入的25在等待 ------- TRX HAS BEEN WAITING 3 SEC FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 47 page no 4 n bits 72 index b of table `burn_test`.`test_purge` trx id 9508 lock_mode X locks gap before rec insert intention waiting ------------------ TABLE LOCK table `burn_test`.`test_purge` trx id 9508 lock mode IX ---TRANSACTION 9503, ACTIVE 10 sec MySQL thread id 7, OS thread handle 139922002028288, query id 44 localhost root cleaning up TABLE LOCK table `burn_test`.`test_purge` trx id 9503 lock mode IX RECORD LOCKS space id 47 page no 4 n bits 72 index b of table `burn_test`.`test_purge` trx id 9503 lock mode S 1: len 4; hex 80000002; asc ;; RECORD LOCKS space id 47 page no 4 n bits 72 index b of table `burn_test`.`test_purge` trx id 9503 lock mode S locks gap before rec Record lock, heap no 6 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 1: len 4; hex 80000007; asc ;;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有