当前位置:网站首页>MySQL transaction isolation level experiment
MySQL transaction isolation level experiment
2022-06-13 03:18:00 【flyweight_ visitor】
Quick start
command
- Connect to database
mysql -uroot -p
mysql> use testdb
- Prepare the data
mysql> CREATE TABLE child (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
mysql> INSERT INTO child (id) values (90),(102);
- View the current database isolation level
SELECT @@global.tx_isolation;

set global transaction isolation level read committed;
set global transaction isolation level repeatable read;
- conversation 1
mysql> START TRANSACTION;
mysql> SELECT * FROM child WHERE id > 100 FOR UPDATE;
- Conversation two
mysql> START TRANSACTION;
mysql> INSERT INTO child (id) VALUES (101);
- Conversation 3 ( View lock wait )
SELECT waiting_trx_id, waiting_pid, waiting_query, blocking_trx_id, blocking_pid, blocking_query FROM sys.innodb_lock_waits;

SELECT
r.trx_id waiting_trx_id,
r.trx_mysql_thread_id waiting_thread,
r.trx_query waiting_query,
b.trx_id blocking_trx_id,
b.trx_mysql_thread_id blocking_thread,
b.trx_query blocking_query
FROM information_schema.innodb_lock_waits w
INNER JOIN information_schema.innodb_trx b
ON b.trx_id = w.blocking_trx_id
INNER JOIN information_schema.innodb_trx r
ON r.trx_id = w.requesting_trx_id;
- conversation 1
mysql> SELECT * FROM child WHERE id > 100 FOR UPDATE;

mysql> SELECT * FROM child WHERE id > 100;

8. conversation 3
mysql> SELECT trx_id, trx_state, trx_started, trx_wait_started, trx_mysql_thread_id, trx_rows_locked, trx_isolation_level FROM information_schema.innodb_trx;

mysql> SELECT * FROM information_schema.innodb_locks;

mysql> SELECT * FROM information_schema.innodb_lock_waits;

mysql> SHOW ENGINE INNODB STATUS;

Reference material
边栏推荐
- Array in PHP array function_ Slice and array_ flip
- When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed
- The use of curl in PHP
- Transaction processing in PDO
- Capital digit to number format
- Keil去掉烦人的ST-Link更新提示
- C method parameter: out
- PK of dotnet architecture
- Hash table: whether alien languages are sorted
- Install MySQL database
猜你喜欢

Age anxiety? How to view the 35 year old programmer career crisis?

Applet image component long press to identify supported codes

Use and arrangement of wechat applet coordinate position interface (I)

Available types in C #_ Unavailable type_ C double question mark_ C question mark point_ C null is not equal to

2-year experience summary to tell you how to do a good job in project management

2021-08-30 distributed cluster

Pytorch record: pytorch variables parameter and buffer. self. register_ buffer()、self. register_ parameter()

Spark Foundation
![[JVM series 8] overview of JVM knowledge points](/img/e5/902de6398359b75183aa1fafcaa7d1.jpg)
[JVM series 8] overview of JVM knowledge points

JS merge multiple string arrays to maintain the original order and remove duplicates
随机推荐
最近最少使用缓存(来源力扣)
Spark Foundation
English语法_方式副词-位置
Pytorch record: pytorch variables parameter and buffer. self. register_ buffer()、self. register_ parameter()
This article takes you to learn DDD, basic introduction
Coordinate location interface of wechat applet (II) map plug-in
2-year experience summary to tell you how to do a good job in project management
How to manage the IT R & D department?
Linked list: palindrome linked list
PHP uses the header function to download files
On the career crisis of programmers at the age of 35
[JVM Series 5] performance testing tool
Time processing class in PHP
开源-校园论坛和资源共享小程序
Polymorphism in golang
Brew tool - "fatal: could not resolve head to a revision" error resolution
C method parameter: params
Summary of the latest IOS interview questions in June 2020 (answers)
【pytorch 記錄】pytorch的變量parameter、buffer。self.register_buffer()、self.register_parameter()
Spoon database insert table operation