Skip to content

Instantly share code, notes, and snippets.

@explorer14
Created July 23, 2021 22:45
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 explorer14/6765ac93b696b54a10a53e3ea01051cb to your computer and use it in GitHub Desktop.
Save explorer14/6765ac93b696b54a10a53e3ea01051cb to your computer and use it in GitHub Desktop.
#Transaction 1
set autocommit = off;
set SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE ;
start transaction;
select * from TrxDb.Products where Id = 1000;
do sleep(8);
update TrxDb.Products set stock = 8 where Id = 1000 and Version = 1;
#Transaction 2
set autocommit = off;
set SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE ;
start transaction;
do sleep(5);
select * from TrxDb.Products where Id = 1000;
update TrxDb.Products set stock = 8 where Id = 1000 and Version = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment