InnoDB意向锁和插入意向锁
- Intention shared lock(IS): It indicates that a transaction is setting(or going to set) a shared lock on several rows for shared query operations.
- Intention exclusive lock(IX): It indicates that a transaction is setting(or going to set) a exclusive lock on several rows for exclusive modification operations.
X |
IX |
S |
IS |
|
|---|---|---|---|---|
X |
Conflict | Conflict | Conflict | Conflict |
IX |
Conflict | Compatible | Conflict | Compatible |
S |
Conflict | Conflict | Compatible | Compatible |
IS |
Conflict | Compatible | Compatible | Compatible |
zlm@192.168.56.100: [zlm]>select @@transaction_isolation;
+-------------------------+
| @@transaction_isolation |
+-------------------------+
| REPEATABLE-READ |
+-------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>show variables like '%status%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| innodb_status_output | ON | //If set "on",it prints innodb status into error log and refresh every 20s by default.
| innodb_status_output_locks | OFF | //If set "off",there're no intention locks in result of "show engine innodb status;".
+----------------------------+-------+
rows in set (0.01 sec) zlm@192.168.56.100: [(none)]>select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
| | //If does not specify "begin" or "start transaction" to explicitly generate a transaction,it commits after typing enter.
+--------------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>show create table t\G
*************************** . row ***************************
Table: t
Create Table: CREATE TABLE `t` (
`id` int() NOT NULL,
`name` char() DEFAULT NULL,
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
row in set (0.01 sec) zlm@192.168.56.100: [zlm]>begin;select * from t where name = 'aaa' lock in share mode;
Query OK, rows affected (0.00 sec) +----+------+
| id | name |
+----+------+
| | aaa |
+----+------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>select * from t for update;
+----+------+
| id | name |
+----+------+
| | aaa |
| | bbb |
| | ccc |
| | fff |
+----+------+
rows in set (0.00 sec) [root@zlm1 :: /data/mysql/mysql3306/data]
#echo '' > error.log [root@zlm1 :: /data/mysql/mysql3306/data]
#tail -f error.log ...
------------
TRANSACTIONS
------------
Trx id counter
Purge done for trx's n:o < 2996003 undo n:o < 0 state: running but idle
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION , ACTIVE sec
lock struct(s), heap size , row lock(s)
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm
... ----------------------------
END OF INNODB MONITOR OUTPUT
============================
^C //There're no intention locks at all.
zlm@192.168.56.100: [zlm]>set @@global.innodb_status_output_locks=on;
Query OK, rows affected (0.00 sec) zlm@192.168.56.100: [zlm]>exit
Bye [root@zlm1 :: /data/mysql/mysql3306/data]
#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. zlm@192.168.56.100: [(none)]>select @@transaction_isolation;
+-------------------------+
| @@transaction_isolation |
+-------------------------+
| REPEATABLE-READ |
+-------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>select @@global.innodb_status_output_locks;
+-------------------------------------+
| @@global.innodb_status_output_locks |
+-------------------------------------+
| |
+-------------------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>select @@global.innodb_status_output;
+-------------------------------+
| @@global.innodb_status_output |
+-------------------------------+
| |
+-------------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
| |
+--------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>use zlm
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
zlm@192.168.56.100: [zlm]>begin;select * from t where name = 'aaa' lock in share mode;
Query OK, rows affected (0.00 sec) +----+------+
| id | name |
+----+------+
| | aaa |
+----+------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>select * from t for update;
+----+------+
| id | name |
+----+------+
| | aaa |
| | bbb |
| | ccc |
| | fff |
+----+------+
rows in set (0.00 sec) [root@zlm1 :: /data/mysql/mysql3306/data]
#tail -f error.log ...
------------
TRANSACTIONS
------------
Trx id counter
Purge done for trx's n:o < 2996003 undo n:o < 0 state: running but idle
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION , ACTIVE sec
lock struct(s), heap size , row lock(s)
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm
TABLE LOCK table `zlm`.`t` trx id lock mode IS //Here's an "IS" intention lock generated by "select ... lock in share mode;" operation.
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock mode S //Here's a "S" shared lock of records.
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex 73757072656d756d; asc supremum;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a8000002610110; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc aaa ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261011f; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc bbb ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261012e; asc a .;;
: len ; hex ; asc ;;
: len ; hex ; asc ccc ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db721; asc - !;;
: len ; hex 360000012c2a35; asc ,*;;
: len ; hex ; asc ;;
: len ; hex ; asc fff ;; TABLE LOCK table `zlm`.`t` trx id lock mode IX //Here's an "IX" intertion lock generated by "select ... for update;" operation.
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X //Here's a "X" exclusive lock of records.
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex 73757072656d756d; asc supremum;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a8000002610110; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc aaa ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261011f; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc bbb ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261012e; asc a .;;
: len ; hex ; asc ;;
: len ; hex ; asc ccc ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db721; asc - !;;
: len ; hex 360000012c2a35; asc ,*;;
: len ; hex ; asc ;;
: len ; hex ; asc fff ;;
... ----------------------------
END OF INNODB MONITOR OUTPUT
============================
^C //We've got an "IS" intention loc,an "IX" intention lock,four "S" locks and four "X" locks.
//Why does "slect ... where name = 'aaa' lock in share mode;" operation holds four "S" locks while we just specify one line?'cause "name" column does not has index key on it.
//Therefore,if we need to observe the intention locks.The variable of "innodb_status_output_locks" should be set "on".
//Session 1:
zlm@192.168.56.100: [zlm]>select @@global.innodb_status_output;
+-------------------------------+
| @@global.innodb_status_output |
+-------------------------------+
| |
+-------------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
| |
+--------------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>begin;select * from t where name = 'aaa' lock in share mode;
Query OK, rows affected (0.00 sec) +----+------+
| id | name |
+----+------+
| | aaa |
+----+------+
row in set (0.00 sec) //Session 2:
zlm@192.168.56.100: [(none)]>select @@global.innodb_status_output_locks;
+-------------------------------------+
| @@global.innodb_status_output_locks |
+-------------------------------------+
| |
+-------------------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>select @@global.innodb_status_output;
+-------------------------------+
| @@global.innodb_status_output |
+-------------------------------+
| |
+-------------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
| |
+--------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>begin;select * from t for update;
Query OK, rows affected (0.00 sec) ERROR (3D000): No database selected
zlm@192.168.56.100: [(none)]>begin;select * from zlm.t for update;
Query OK, rows affected (0.00 sec) ERROR (HY000): Lock wait timeout exceeded; try restarting transaction //Wait for 50 seconds(by default) then becomes timeout.
zlm@192.168.56.100: [(none)]> //Check the lock information in error log.
[root@zlm1 :: /data/mysql/mysql3306/data]
#tail -f error.log ...
------------
TRANSACTIONS
------------
Trx id counter
Purge done for trx's n:o < 2996003 undo n:o < 0 state: running but idle
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION , ACTIVE sec starting index read
mysql tables in use , locked
LOCK WAIT lock struct(s), heap size , row lock(s)
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm Sending data
select * from zlm.t for update
------- TRX HAS BEEN WAITING SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X waiting
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a8000002610110; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc aaa ;; ------------------
TABLE LOCK table `zlm`.`t` trx id lock mode IX
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X waiting
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a8000002610110; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc aaa ;; ...
----------------------------
END OF INNODB MONITOR OUTPUT
============================
^C //Only an "IX" intention lock and an "X" record lock were found.There's no "IS" intention lock any more.
//Intention locks between transactons does not block each other,they don't conflict.Therefore,when session 2 is gonna to get "X" lock(for update),the "IX" intention lock was generated and the "IS" intention in session 1 didn't appear.
//How about reversing the operations in session 1 and session 2?Let's see below. //Session 1:
zlm@192.168.56.100: [zlm]>begin;select * from t for update;
Query OK, rows affected (0.00 sec) +----+------+
| id | name |
+----+------+
| | aaa |
| | bbb |
| | ccc |
| | fff |
+----+------+
rows in set (0.00 sec) //Session 2:
zlm@192.168.56.100: [(none)]>begin;select * from t where name = 'aaa' lock in share mode;
Query OK, rows affected (0.00 sec) ERROR (3D000): No database selected
zlm@192.168.56.100: [(none)]>begin;select * from zlm.t where name = 'aaa' lock in share mode;
Query OK, rows affected (0.00 sec) ERROR (HY000): Lock wait timeout exceeded; try restarting transaction
zlm@192.168.56.100: [(none)]> //Check the error log.
[root@zlm1 :: /data/mysql/mysql3306/data]
#tail -f error.log ...
------------
TRANSACTIONS
------------
Trx id counter
Purge done for trx's n:o < 2996003 undo n:o < 0 state: running but idle
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION , ACTIVE sec
lock struct(s), heap size , row lock(s)
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm
TABLE LOCK table `zlm`.`t` trx id lock mode IX
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex 73757072656d756d; asc supremum;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a8000002610110; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc aaa ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261011f; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc bbb ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261012e; asc a .;;
: len ; hex ; asc ;;
: len ; hex ; asc ccc ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db721; asc - !;;
: len ; hex 360000012c2a35; asc ,*;;
: len ; hex ; asc ;;
: len ; hex ; asc fff ;; ...
----------------------------
END OF INNODB MONITOR OUTPUT
============================
^C //We've still get merely "IX" intention lock.The different is that there're four "X" record lock genrated by session 1 and they blocks the session 2 to hold shared read lock on those records,becuase "X" record locks confilct with both "X" and "S" record locks.Remember that we have no index key on column "name" and "select ... where name = 'aaa' lock in share mode;" mean to hold all the "S" record locks on the "name" column.
//Session 1:
zlm@192.168.56.100: [(zlm)]>select @@transaction_isolation;
+-------------------------+
| @@transaction_isolation |
+-------------------------+
| REPEATABLE-READ |
+-------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [zlm]>begin;select * from t for update;
Query OK, rows affected (0.00 sec) +----+------+
| id | name |
+----+------+
| | aaa |
| | bbb |
| | ccc |
| | fff |
+----+------+
rows in set (0.00 sec) //Session 2:
zlm@192.168.56.100: [(zlm)]>select @@transaction_isolation;
+-------------------------+
| @@transaction_isolation |
+-------------------------+
| REPEATABLE-READ |
+-------------------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>begin;insert into zlm.t values(,'eee');
Query OK, rows affected (0.00 sec) ERROR (HY000): Lock wait timeout exceeded; try restarting transaction
zlm@192.168.56.100: [(none)]> //Check the error log for detail of locks.
[root@zlm1 :: /data/mysql/mysql3306/data]
#tail -f error.log ...
------------
TRANSACTIONS
------------
Trx id counter
Purge done for trx's n:o < 2996020 undo n:o < 0 state: running but idle
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION , ACTIVE sec inserting
mysql tables in use , locked
LOCK WAIT lock struct(s), heap size , row lock(s) //The two lock structs were intention lock("IX") and insert intention lock.
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm update
insert into zlm.t values(,'eee')
------- TRX HAS BEEN WAITING SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X insert intention waiting
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex 73757072656d756d; asc supremum;; //Session 1 holds all "X" record locks of table "t".So it showed supremum what means the gap is infinite and no record can be inserted into the table at all. ------------------
TABLE LOCK table `zlm`.`t` trx id lock mode IX //The "IX" intention lock of session 2.
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X insert intention waiting
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex 73757072656d756d; asc supremum;; ---TRANSACTION , ACTIVE sec
lock struct(s), heap size , row lock(s)
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm
TABLE LOCK table `zlm`.`t` trx id lock mode IX //The "IX" intention lock of session 1.
RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex 73757072656d756d; asc supremum;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a8000002610110; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc aaa ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261011f; asc a ;;
: len ; hex ; asc ;;
: len ; hex ; asc bbb ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261012e; asc a .;;
: len ; hex ; asc ;;
: len ; hex ; asc ccc ;; Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db721; asc - !;;
: len ; hex 360000012c2a35; asc ,*;;
: len ; hex ; asc ;;
: len ; hex ; asc fff ;; ...
----------------------------
END OF INNODB MONITOR OUTPUT
============================
^C //Session 2 meant to get an insert intention lock when it was executing "insert into xxx" but waited until timeout.
//Whatif we only lock a certain record,what will session do then?Let's see below. //Session 1:
zlm@192.168.56.100: [zlm]>begin;select * from t where id= for update;
Query OK, rows affected (0.00 sec) +----+------+
| id | name |
+----+------+
| | ccc |
+----+------+
row in set (0.00 sec) //Session 2:
zlm@192.168.56.100: [(none)]>begin;insert into zlm.t values(,'ccc');
ERROR (HY000): Lock wait timeout exceeded; try restarting transaction
zlm@192.168.56.100: [(none)]> //Check error log again.
[root@zlm1 :: /data/mysql/mysql3306/data]
#tail -f error.log ...
------------
TRANSACTIONS
------------
Trx id counter
Purge done for trx's n:o < 2996020 undo n:o < 0 state: running but idle
History list length
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION , ACTIVE sec inserting
mysql tables in use , locked
LOCK WAIT lock struct(s), heap size , row lock(s), undo log entries
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm update
insert into zlm.t values(,'ccc')
------- TRX HAS BEEN WAITING SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id page no n bits index id of table `zlm`.`t` trx id lock_mode X locks gap before rec insert intention waiting
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex ; asc ;; ------------------
TABLE LOCK table `zlm`.`t` trx id lock mode IX
RECORD LOCKS space id page no n bits index id of table `zlm`.`t` trx id lock_mode X locks gap before rec insert intention waiting
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex ; asc ;; ---TRANSACTION , ACTIVE sec
lock struct(s), heap size , row lock(s)
MySQL thread id , OS thread handle , query id zlm1 192.168.56.100 zlm
TABLE LOCK table `zlm`.`t` trx id lock mode IX
RECORD LOCKS space id page no n bits index id of table `zlm`.`t` trx id lock_mode X
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex ; asc ;; RECORD LOCKS space id page no n bits index GEN_CLUST_INDEX of table `zlm`.`t` trx id lock_mode X locks rec but not gap
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex 0000002db708; asc - ;;
: len ; hex a800000261012e; asc a .;;
: len ; hex ; asc ;;
: len ; hex ; asc ccc ;; RECORD LOCKS space id page no n bits index id of table `zlm`.`t` trx id lock_mode X locks gap before rec
Record lock, heap no PHYSICAL RECORD: n_fields ; compact format; info bits
: len ; hex ; asc ;;
: len ; hex ; asc ;; //The locks seem to be more and more complicated.
//Session 1(TRANSACTION 2996023) holded an "IX" intention lock,a "X" record lock,two gap locks.
//Session 2(TRANSACTION 2996024) asked for holded an "IX" intention lock and asked for an intert intention lock which was relevant with the gap before the record it meant to insert.The transaction of session 2 waited until timeout.
- intention locks are table-level locks created by InnoDB automatically when we have intentions to modify a certain record(or some of relevant records) in these tables.
- The main effect of intention locks is to make InnoDB be more compatible in multidimensional lock granularity(both table-level and row-level locks).
- It can simplify the mechanism in checking record locks of a certain table.For exmple,MySQL don't need to retrieve the full table when a client(or session) is modifying(or going to modify) records in that table.
- The variables "innodb_status_output_locks" should be set "on",if we want to see them in the output of "show engine innodb status" statement.
- Insert intention locks is similar with intention locks but it's merely relevant with those insert operations.
InnoDB意向锁和插入意向锁的更多相关文章
- InnoDB的锁机制浅析(二)—探索InnoDB中的锁(Record锁/Gap锁/Next-key锁/插入意向锁)
Record锁/Gap锁/Next-key锁/插入意向锁 文章总共分为五个部分: InnoDB的锁机制浅析(一)-基本概念/兼容矩阵 InnoDB的锁机制浅析(二)-探索InnoDB中的锁(Recor ...
- mysql innodb插入意向锁
innodb中有插入意向锁.专门针对insert,假设插入前,该间隙已经由gap锁,那么Insert会申请插入意向锁. 那么这个插入意向锁的作用是什么? 1.为了唤起等待.由于该间隙已经有锁,插入时必 ...
- innodb insert buffer 插入缓冲区的理解
今天在做一个大业务的数据删除时,看到下面的性能曲线图 在删除动作开始之后,insert buffer 大小增加到140.对于这些状态参数的说明 InnoDB Insert Buffer 插入缓冲,并不 ...
- python,java操作mysql数据库,数据引擎设置为myisam时能够插入数据,转为innodb时无法插入数据
今天想给数据库换一个数据引擎,mysiam转为 innodb 结果 python 插入数据时失败,但是自增id值是存在的, 换回mysiam后,又可以插入了~~ 想换php插入试试,结果php数据引擎 ...
- InnoDB Insert(插入)操作(下)--mysql技术内幕
接上一篇文章,最后做的那个实验,我是想证明mysql innodb存储引擎,commit操作与flush数据到磁盘之间的关系,当与同事交流之后,他说,你应该把innodb_buffer_size的大小 ...
- InnoDB的锁机制浅析(四)—不同SQL的加锁状况
不同SQL的加锁状况 文章总共分为五个部分: InnoDB的锁机制浅析(一)-基本概念/兼容矩阵 InnoDB的锁机制浅析(二)-探索InnoDB中的锁(Record锁/Gap锁/Next-key锁/ ...
- InnoDB的锁机制浅析(All in One)
目录 InnoDB的锁机制浅析 1. 前言 2. 锁基本概念 2.1 共享锁和排它锁 2.2 意向锁-Intention Locks 2.3 锁的兼容性 3. InnoDB中的锁 3.1 准备工作 3 ...
- (转)InnoDB存储引擎MVCC实现原理
InnoDB存储引擎MVCC实现原理 原文:https://liuzhengyang.github.io/2017/04/18/innodb-mvcc/ 简单背景介绍 MySQL MySQL是现在最流 ...
- MySql InnoDB中的锁研究
# MySql InnoDB中的锁研究 ## 1.InnoDB中有哪些锁### 1. 共享和排他(独占)锁(Shared and Exclusive Locks) InnoDB实现标准的行级锁定,其中 ...
随机推荐
- js 页面 json对象转数组
json_array(data); function json_array(data){ var len=eval(data).length; var arr=[]; for(var i=0;i< ...
- 启用 DHCP
#开启DHCP协议 Get-NetIPInterface -Dhcp Disabled|Set-NetIPInterface -Dhcp Enabled #开启本机上所有博通网卡的DHCP Get-W ...
- LVS的DR模式负载均衡
参考项目:http://www.cnblogs.com/along21/p/7833261.html#auto_id_3 LVS的DR模式实现负载均衡 1.环境 lvs-server :192.168 ...
- PAT——1005. 继续(3n+1)猜想 (25)
卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数.例如对n=3进行验证的时候, ...
- #warning Incomplete method implementation怎么修改?
#warning Incomplete method implementation怎么修改? 各位朋友,我在做一个表格视图的例子,在tableview方法里总有几个warning:#war ...
- js的匿名函数与自定义函数
//匿名方法,会执行,自己调用自己 (function () { console.log(window.innerHeight); })(); (function () { console.log(w ...
- 关于结构体占用空间大小总结(#pragma pack的使用)
关于C/C++中结构体变量占用内存大小的问题,之前一直以为把这个问题搞清楚了,今天看到一道题,发现之前的想法完全是错误的.这道题是这样的: 在32位机器上,下面的代码中 class A { publi ...
- python3爬虫编码问题
使用爬虫爬取网页经常遇到各种编码问题,因此产生乱码今天折腾了一天,全部总结一遍环境:win10,pycharm,python3.41.首先先来网页编码是utf-8的:以百度首页为例:使用request ...
- Knowledge Point 20180305 Java程序员详述编码Unicode
Unicode Unicode(统一码.万国码.单一码)是计算机科学领域里的一项业界标准,包括字符集.编码方案等.Unicode 是为了解决传统的字符编码方案的局限而产生的,它为每种语言中的每个字符设 ...
- Unity 游戏框架搭建 (十七) 静态扩展GameObject实现链式编程
本篇本来是作为原来 优雅的QChain的第一篇的内容,但是QChain流产了,所以收录到了游戏框架搭建系列.本篇介绍如何实现GameObject的链式编程. 链式编程的实现技术之一是C#的静态扩展.静 ...