Skip to content

Instantly share code, notes, and snippets.

@ssippe
Created May 15, 2020 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssippe/83b90c06ed62e0a159c4aec3958a547b to your computer and use it in GitHub Desktop.
Save ssippe/83b90c06ed62e0a159c4aec3958a547b to your computer and use it in GitHub Desktop.
mysql force deadlock
-- replace:
-- `log` with any table
-- `id` with any index column on that table
-- 81272070 with an existing value in the index column
-- in connection #1
START transaction;
select * from log where id = 81272070 FOR UPDATE;
select sleep(40);
COMMIT;
-- in connection #2
select * from log where id = 81272070 FOR UPDATE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment