postgresql/src/test/isolation/expected/nowait.out
Alvaro Herrera eeab936ba9 Fix FOR UPDATE NOWAIT on updated tuple chains
If SELECT FOR UPDATE NOWAIT tries to lock a tuple that is concurrently
being updated, it might fail to honor its NOWAIT specification and block
instead of raising an error.

Fix by adding a no-wait flag to EvalPlanQualFetch which it can pass down
to heap_lock_tuple; also use it in EvalPlanQualFetch itself to avoid
blocking while waiting for a concurrent transaction.

Authors: Craig Ringer and Thomas Munro, tweaked by Álvaro
http://www.postgresql.org/message-id/51FB6703.9090801@2ndquadrant.com

Per Thomas Munro in the course of his SKIP LOCKED feature submission,
who also provided one of the isolation test specs.

Backpatch to 9.4, because that's as far back as it applies without
conflicts (although the bug goes all the way back).  To that branch also
backpatch Thomas Munro's new NOWAIT test cases, committed in master by
Heikki as commit 9ee16b49f0 .
2014-08-27 19:15:18 -04:00

65 lines
1.7 KiB
Text

Parsed test spec with 2 sessions
starting permutation: s1a s1b s2a s2b
step s1a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s1b: COMMIT;
step s2a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s2b: COMMIT;
starting permutation: s1a s2a s1b s2b
step s1a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s2a: SELECT * FROM foo FOR UPDATE NOWAIT;
ERROR: could not obtain lock on row in relation "foo"
step s1b: COMMIT;
step s2b: COMMIT;
starting permutation: s1a s2a s2b s1b
step s1a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s2a: SELECT * FROM foo FOR UPDATE NOWAIT;
ERROR: could not obtain lock on row in relation "foo"
step s2b: COMMIT;
step s1b: COMMIT;
starting permutation: s2a s1a s1b s2b
step s2a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s1a: SELECT * FROM foo FOR UPDATE NOWAIT;
ERROR: could not obtain lock on row in relation "foo"
step s1b: COMMIT;
step s2b: COMMIT;
starting permutation: s2a s1a s2b s1b
step s2a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s1a: SELECT * FROM foo FOR UPDATE NOWAIT;
ERROR: could not obtain lock on row in relation "foo"
step s2b: COMMIT;
step s1b: COMMIT;
starting permutation: s2a s2b s1a s1b
step s2a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s2b: COMMIT;
step s1a: SELECT * FROM foo FOR UPDATE NOWAIT;
id data
1 x
step s1b: COMMIT;