Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bb4aed4

Browse files
committed
Shut down EvalPlanQual machinery when LockRows node reaches the end.
Previously, we left the EPQ sub-executor alone until ExecEndLockRows. This caused any buffer pins or other resources that it might hold to remain held until ExecutorEnd, which in some code paths means that they are held till the Portal is closed. That can cause user-visible problems, such as blocking VACUUM; and it's unlike the behavior of ordinary table-scanning nodes, which will have released all buffer pins by the time they return an EOF indication. We can make LockRows work more like other plan nodes by calling EvalPlanQualEnd just before returning NULL. We still need to call it in ExecEndLockRows in case the node was not run to completion, but in the normal case the second call does nothing and costs little. Per report from Yura Sokolov. In principle this is a longstanding bug, but in view of the lack of other complaints and the low severity of the consequences, I chose not to back-patch. Discussion: https://postgr.es/m/4aa370cb91ecf2f9885d98b80ad1109c@postgrespro.ru
1 parent 9bb5eec commit bb4aed4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/executor/nodeLockRows.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ ExecLockRows(PlanState *pstate)
5959
slot = ExecProcNode(outerPlan);
6060

6161
if (TupIsNull(slot))
62+
{
63+
/* Release any resources held by EPQ mechanism before exiting */
64+
EvalPlanQualEnd(&node->lr_epqstate);
6265
return NULL;
66+
}
6367

6468
/* We don't need EvalPlanQual unless we get updated tuple version(s) */
6569
epq_needed = false;
@@ -381,6 +385,7 @@ ExecInitLockRows(LockRows *node, EState *estate, int eflags)
381385
void
382386
ExecEndLockRows(LockRowsState *node)
383387
{
388+
/* We may have shut down EPQ already, but no harm in another call */
384389
EvalPlanQualEnd(&node->lr_epqstate);
385390
ExecEndNode(outerPlanState(node));
386391
}

0 commit comments

Comments
 (0)