Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Always call ExecShutdownNode() if appropriate.
authorThomas Munro <tmunro@postgresql.org>
Fri, 15 Nov 2019 21:04:52 +0000 (10:04 +1300)
committerThomas Munro <tmunro@postgresql.org>
Fri, 15 Nov 2019 21:19:16 +0000 (10:19 +1300)
Call ExecShutdownNode() after ExecutePlan()'s loop, rather than at each
break.  We had forgotten to do that in one case.  The omission caused
intermittent "temporary file leak" warnings from multi-batch parallel
hash joins with a LIMIT clause.

Back-patch to 11.  Though the problem exists in theory in earlier
parallel query releases, nothing really depended on it.

Author: Kyotaro Horiguchi
Reviewed-by: Thomas Munro, Amit Kapila
Discussion: https://postgr.es/m/20191111.212418.2222262873417235945.horikyota.ntt%40gmail.com

src/backend/executor/execMain.c

index 0abb620050bd0480f7918c37ec4e52546e75d5fe..de9aaf3f766e89210556c55b864a5bda9264303a 100644 (file)
@@ -1727,15 +1727,7 @@ ExecutePlan(EState *estate,
         * process so we just end the loop...
         */
        if (TupIsNull(slot))
-       {
-           /*
-            * If we know we won't need to back up, we can release resources
-            * at this point.
-            */
-           if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
-               (void) ExecShutdownNode(planstate);
            break;
-       }
 
        /*
         * If we have a junk filter, then project a new tuple with the junk
@@ -1778,17 +1770,16 @@ ExecutePlan(EState *estate,
         */
        current_tuple_count++;
        if (numberTuples && numberTuples == current_tuple_count)
-       {
-           /*
-            * If we know we won't need to back up, we can release resources
-            * at this point.
-            */
-           if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
-               (void) ExecShutdownNode(planstate);
            break;
-       }
    }
 
+   /*
+    * If we know we won't need to back up, we can release resources at this
+    * point.
+    */
+   if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
+       (void) ExecShutdownNode(planstate);
+
    if (use_parallel_mode)
        ExitParallelMode();
 }