Created
May 8, 2017 12:42
-
-
Save teddy-hoo/5b45a98c5b5b259cef363610253405c7 to your computer and use it in GitHub Desktop.
reproduce a deadlock in mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # session 1 | |
| use test; | |
| create table t (i int) engine = InnoDB; | |
| insert into t(i) values(1); | |
| start transaction; | |
| select * from t where i = 1 lock in share mode; | |
| # session 2 | |
| use test; | |
| start transaction; | |
| delete from t where i = 1; | |
| # session 1 | |
| delete from t where i = 1; | |
| # session 1 output | |
| Query OK, 1 row affected (0.02 sec) | |
| # session 2 output | |
| ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting taction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment