Fix buffer usage stats for nodes above Gather Merge.
authorAmit Kapila <[email protected]>
Sat, 25 Jul 2020 05:27:20 +0000 (10:57 +0530)
committerAmit Kapila <[email protected]>
Sat, 25 Jul 2020 05:27:20 +0000 (10:57 +0530)
Commit 85c9d347 addressed a similar problem for Gather and Gather
Merge nodes but forgot to account for nodes above parallel nodes.  This
still works for nodes above Gather node because we shut down the workers
for Gather node as soon as there are no more tuples.  We can do a similar
thing for Gather Merge as well but it seems better to account for stats
during nodes shutdown after completing the execution.

Reported-by: Stéphane Lorek, Jehan-Guillaume de Rorthais
Author: Jehan-Guillaume de Rorthais <[email protected]>
Reviewed-by: Amit Kapila
Backpatch-through: 10, where it was introduced
Discussion: https://postgr.es/m/20200718160206.584532a2@firost

src/backend/executor/execProcnode.c

index d87fb05abfb6e7d4d053f17b0fded35654c3bbe5..ed78cf82c1060941d4e30540bdebd90c29b6ab4c 100644 (file)
@@ -731,8 +731,6 @@ ExecShutdownNode(PlanState *node)
 
    check_stack_depth();
 
-   planstate_tree_walker(node, ExecShutdownNode, NULL);
-
    /*
     * Treat the node as running while we shut it down, but only if it's run
     * at least once already.  We don't expect much CPU consumption during
@@ -746,6 +744,8 @@ ExecShutdownNode(PlanState *node)
    if (node->instrument && node->instrument->running)
        InstrStartNode(node->instrument);
 
+   planstate_tree_walker(node, ExecShutdownNode, NULL);
+
    switch (nodeTag(node))
    {
        case T_GatherState: