From 1c9701cfe58267cf5d79543a42ee4f0967cc73ab Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 27 Aug 2014 19:15:18 -0400 Subject: Fix FOR UPDATE NOWAIT on updated tuple chains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 . --- src/include/executor/executor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include/executor') diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 239aff32088..02661350d94 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -199,7 +199,7 @@ extern TupleTableSlot *EvalPlanQual(EState *estate, EPQState *epqstate, Relation relation, Index rti, int lockmode, ItemPointer tid, TransactionId priorXmax); extern HeapTuple EvalPlanQualFetch(EState *estate, Relation relation, - int lockmode, ItemPointer tid, TransactionId priorXmax); + int lockmode, bool noWait, ItemPointer tid, TransactionId priorXmax); extern void EvalPlanQualInit(EPQState *epqstate, EState *estate, Plan *subplan, List *auxrowmarks, int epqParam); extern void EvalPlanQualSetPlan(EPQState *epqstate, -- cgit v1.2.3