]> granicus.if.org Git - postgresql/commitdiff
Avoid server crash when worker registration fails at execution time.
authorRobert Haas <rhaas@postgresql.org>
Fri, 20 Nov 2015 18:03:39 +0000 (13:03 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 20 Nov 2015 18:03:39 +0000 (13:03 -0500)
The previous coding attempts to destroy the DSM in this case, but
child nodes might have stored data there and still be holding onto
pointers in this case.  So don't do that.

Also, free the reader array instead of leaking it.

Extracted from two different patch versions both by Amit Kapila.

src/backend/executor/nodeGather.c

index b6e82d1664f83dedcdf1e1eb8e8e35071ffcff76..f8c1ba637d316028a984dce5749de76f5139c37b 100644 (file)
@@ -190,7 +190,7 @@ ExecGather(GatherState *node)
 
                        /* No workers?  Then never mind. */
                        if (!got_any_worker)
-                               ExecShutdownGather(node);
+                               ExecShutdownGatherWorkers(node);
                }
 
                /* Run plan locally if no workers or not single-copy. */
@@ -402,6 +402,8 @@ ExecShutdownGatherWorkers(GatherState *node)
 
                for (i = 0; i < node->nreaders; ++i)
                        DestroyTupleQueueReader(node->reader[i]);
+
+               pfree(node->reader);
                node->reader = NULL;
        }