当前位置:网站首页>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
边栏推荐
- C simple understanding - arrays and sets
- P1048 [noip2005 popularization group] Drug collection
- MySQL transactions and locks (V)
- Spoon database insert table operation
- Querywrapper constructor method
- 通过Web ETL统一调度和管理DataX任务
- 二叉樹初始化代碼
- Available types in C #_ Unavailable type_ C double question mark_ C question mark point_ C null is not equal to
- Applet image component long press to identify supported codes
- IOS development interview knowledge sorting - OC Foundation (II)
猜你喜欢
Installing the IK word breaker
Scala implements workcount
English语法_方式副词-位置
MySQL index bottom layer (I)
2019 - sorting out the latest and most comprehensive IOS test questions (including framework and algorithm questions)
C simple understanding - arrays and sets
六款国产飞机专用GPU产品通过鉴定审查
Wechat applet switch style rewriting
Applet image component long press to identify supported codes
【pytorch 记录】pytorch的变量parameter、buffer。self.register_buffer()、self.register_parameter()
随机推荐
Brew tool - "fatal: could not resolve head to a revision" error resolution
Supervisor -- Process Manager
Radium laser radar C16 data to PCD (based on ROS)
When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed
How to become a technological bull -- from the bull man
Add Yum source to install php74
【同步功能】2.0.16-19 版本都有同步功能修复的更新,但未解决问题
Review notes of RS data communication foundation STP
PK of dotnet architecture
MySQL transactions and locks (V)
Entity framework extends the actual combat, small project reconfiguration, no trouble
MySQL create user authorization remote access
Transaction processing in PDO
Level II C preparation -- basic concepts of program design
brew工具-“fatal: Could not resolve HEAD to a revision”错误解决
Control scanner in Delphi
最近最少使用缓存(来源力扣)
[synchronization function] version 2.0.16-19 has the update of synchronization function repair, but the problem has not been solved
Three ways to start WPF project
Five old code farmers, program life review: peace of mind is not the place to go