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实现标准的行级锁定,其中 ...
随机推荐
- 开源项目之kisso
kisso开源项目:https://gitee.com/baomidou/kisso 一.简介 kisso = cookie sso 基于 Cookie 的 SSO 中间件,它是一把快速开发 ja ...
- selenium处理table表格
在UI自动化测试中经常会遇到表格的处理,下面是一点心得. 假设网页页面有一个表格,如何获取这个table的指定cell的值?你会说我们可以根据xpath定位到这个cell的行列,然后getText() ...
- HDU 2048 神、上帝以及老天爷(错排概率问题)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2048 神.上帝以及老天爷 Time Limit: 2000/1000 MS (Java/Others) ...
- 阿贾克斯(AJAX)
AJAX :Asynchronous JavaScript and XML 异步的javascript 和xml 优点 : 在不重新加载整个页面的情况下,可以与服务器交换数据并更新部分数据 不需要 ...
- Oracle 创建触发器实现自增长
Oracle中没有主键,要实现自增长,需要创建触发器,每次插入数据的时候进行ID赋值. 环境:Oracle11,Navicat工具连接 创建了一个表,字段如下(字段名,表名都需要大写,你小写了还无效. ...
- 微信小程序获取手机信息
wx.getSystemInfo({ success: function (res) { console.log(res.model)//手机型号 console.log(res.pixelRatio ...
- AltiumDesigner16笔记
集成库(*.intlib)没有办法直接修改库文件,但是*.schlib可以编辑的. 原理图元件批量修改可以从Tools-> Update from libraries进行. PCB封装批量修改: ...
- 常用Sql server 自定义函数
/****** 对象: UserDefinedFunction [dbo].[fun_get_LowerFirst] 脚本日期: 08/04/2012 13:03:56 ******/ IF EXIS ...
- HDU 5572--An Easy Physics Problem(射线和圆的交点)
An Easy Physics Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- day 18 类与类之间的关系
类与类之间的关系 在我们的世界中事物和事物之间总会有一些联系. 在面向对象中,类和类之间也可以产生相关的关系 1.依赖关系 执行某个动作的时候. 需要xxx来帮助你完成这个操作, ...