Skip to content

Commit 88fdc70

Browse files
committed
Fix possible infinite loop with Parallel Append.
When the previously-chosen plan was non-partial, all pa_finished flags for partial plans are now set, and pa_next_plan has not yet been set to INVALID_SUBPLAN_INDEX, the previous code could go into an infinite loop. Report by Rajkumar Raghuwanshi. Patch by Amit Khandekar and me. Review by Kyotaro Horiguchi. Discussion: http://postgr.es/m/CAJ3gD9cf43z78qY=U=H0HvOEN341qfRO-vLpnKPSviHeWgJQ5w@mail.gmail.com
1 parent b3a101e commit 88fdc70

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/executor/nodeAppend.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ choose_next_subplan_for_worker(AppendState *node)
473473
return false;
474474
}
475475

476+
/* Save the plan from which we are starting the search. */
477+
node->as_whichplan = pstate->pa_next_plan;
478+
476479
/* Loop until we find a subplan to execute. */
477480
while (pstate->pa_finished[pstate->pa_next_plan])
478481
{
@@ -481,14 +484,17 @@ choose_next_subplan_for_worker(AppendState *node)
481484
/* Advance to next plan. */
482485
pstate->pa_next_plan++;
483486
}
484-
else if (append->first_partial_plan < node->as_nplans)
487+
else if (node->as_whichplan > append->first_partial_plan)
485488
{
486489
/* Loop back to first partial plan. */
487490
pstate->pa_next_plan = append->first_partial_plan;
488491
}
489492
else
490493
{
491-
/* At last plan, no partial plans, arrange to bail out. */
494+
/*
495+
* At last plan, and either there are no partial plans or we've
496+
* tried them all. Arrange to bail out.
497+
*/
492498
pstate->pa_next_plan = node->as_whichplan;
493499
}
494500

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy