diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index b368b48..f090b2b 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -188,9 +188,16 @@ ExecGather(GatherState *node)
 				}
 			}
 
-			/* No workers?  Then never mind. */
+			/*
+			 * It is very well possible that no workers are available for
+			 * execution, but still we can't destroy the DSM as that will
+			 * be required for execution in master backend.
+			 */
 			if (!got_any_worker)
-				ExecShutdownGather(node);
+			{
+				pfree(node->reader);
+				node->reader = NULL;
+			}
 		}
 
 		/* Run plan locally if no workers or not single-copy. */
@@ -402,6 +409,8 @@ ExecShutdownGatherWorkers(GatherState *node)
 
 		for (i = 0; i < node->nreaders; ++i)
 			DestroyTupleQueueReader(node->reader[i]);
+
+		pfree(node->reader);
 		node->reader = NULL;
 	}
 
