aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeLimit.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2018-08-03 11:16:25 +0530
committerAmit Kapila <akapila@postgresql.org>2018-08-03 11:16:25 +0530
commitdac7fe13bbf10c249a519d6a41c683c42c7e3312 (patch)
tree1ec7f9977de446f95b8bd24fa3fd036af9dbaeba /src/backend/executor/nodeLimit.c
parentef305bd59d9828805bfdbf33ff4003bb74a63865 (diff)
downloadpostgresql-dac7fe13bbf10c249a519d6a41c683c42c7e3312.tar.gz
postgresql-dac7fe13bbf10c249a519d6a41c683c42c7e3312.zip
Fix buffer usage stats for parallel nodes.
The buffer usage stats is accounted only for the execution phase of the node. For Gather and Gather Merge nodes, such stats are accumulated at the time of shutdown of workers which is done after execution of node due to which we missed to account them for such nodes. Fix it by treating nodes as running while we shut down them. We can also miss accounting for a Limit node when Gather or Gather Merge is beneath it, because it can finish the execution before shutting down such nodes. So we allow a Limit node to shut down the resources before it completes the execution. In the passing fix the gather node code to allow workers to shut down as soon as we find that all the tuples from the workers have been retrieved. The original code use to do that, but is accidently removed by commit 01edb5c7fc. Reported-by: Adrien Nayrat Author: Amit Kapila and Robert Haas Reviewed-by: Robert Haas and Andres Freund Backpatch-through: 9.6 where this code was introduced Discussion: https://postgr.es/m/86137f17-1dfb-42f9-7421-82fd786b04a1@anayrat.info
Diffstat (limited to 'src/backend/executor/nodeLimit.c')
-rw-r--r--src/backend/executor/nodeLimit.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c
index 56d98b4490b..66ea6aa3c35 100644
--- a/src/backend/executor/nodeLimit.c
+++ b/src/backend/executor/nodeLimit.c
@@ -134,6 +134,8 @@ ExecLimit(PlanState *pstate)
node->position - node->offset >= node->count)
{
node->lstate = LIMIT_WINDOWEND;
+ /* Allow nodes to release or shut down resources. */
+ (void) ExecShutdownNode(outerPlan);
return NULL;
}