-
-
Save felixge/83ad53f66a7b3cbc99e32f5326a8ff8b to your computer and use it in GitHub Desktop.
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
DROP TABLE simple; | |
CREATE TABLE simple ( | |
val int | |
); | |
-- After this run t1 and t2 in two different sessions, executing the SQL statements | |
-- in the order given by the commands after them. | |
-- | |
-- Notice how t2 aborts with the error below, even so it should be serializable with t1. | |
-- | |
-- ERROR: could not serialize access due to read/write dependencies among transactions | |
-- DETAIL: Reason code: Canceled on identification as a pivot, during commit attempt. | |
-- HINT: The transaction might succeed if retried. |
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
BEGIN ISOLATION LEVEL SERIALIZABLE; -- 1 | |
INSERT INTO simple (val) VALUES (1); -- 3 | |
SELECT * FROM simple WHERE val = 3; -- 5 | |
COMMIT; --7 |
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
BEGIN ISOLATION LEVEL SERIALIZABLE; -- 2 | |
INSERT INTO simple (val) VALUES (2); -- 4 | |
SELECT * FROM simple WHERE val = 4; -- 6 | |
COMMIT; --8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment