]> granicus.if.org Git - postgresql/commit
Fix FOR UPDATE NOWAIT on updated tuple chains
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 27 Aug 2014 23:15:18 +0000 (19:15 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 27 Aug 2014 23:15:18 +0000 (19:15 -0400)
commiteeab936ba94de70ee5f03e167331f1399914b6db
tree6ecd15b066a9c51b8c0fdee2253845da89567156
parentd4b8418a04f41dc991dc364a0a6eab64b16f2e83
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 9ee16b49f0aac819bd4823d9b94485ef608b34e8 .
15 files changed:
src/backend/executor/execMain.c
src/backend/executor/nodeLockRows.c
src/include/executor/executor.h
src/test/isolation/expected/nowait-2.out [new file with mode: 0644]
src/test/isolation/expected/nowait-3.out [new file with mode: 0644]
src/test/isolation/expected/nowait-4.out [new file with mode: 0644]
src/test/isolation/expected/nowait-4_1.out [new file with mode: 0644]
src/test/isolation/expected/nowait-5.out [new file with mode: 0644]
src/test/isolation/expected/nowait.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/nowait-2.spec [new file with mode: 0644]
src/test/isolation/specs/nowait-3.spec [new file with mode: 0644]
src/test/isolation/specs/nowait-4.spec [new file with mode: 0644]
src/test/isolation/specs/nowait-5.spec [new file with mode: 0644]
src/test/isolation/specs/nowait.spec [new file with mode: 0644]