Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e39ca6

Browse files
committed
Improve fix for not entering parallel mode when holding interrupts.
Commitac04aa8 put the shutoff for this into the planner, which isnot ideal because it doesn't prevent us from re-using a previouslymade parallel plan. Revert the planner change and instead put theshutoff into InitializeParallelDSM, modeling it on the existing codethere for recovering from failure to allocate a DSM segment.However, that code path is mostly untested, and testing a bit hardershowed there's at least one bug: ExecHashJoinReInitializeDSM is notprepared for us to have skipped doing parallel DSM setup. I alsothought the Assert in ReinitializeParallelWorkers is prettyill-advised, and replaced it with a silent Min() operation.The existing test case added byac04aa8 serves fine to test thisversion of the fix, so no change needed there.Patch by me, but thanks to Noah Misch for the core idea that wecould shut off worker creation when !INTERRUPTS_CAN_BE_PROCESSED.Back-patch to v12, asac04aa8 was.Discussion:https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com
1 parent9c47574 commit6e39ca6

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ InitializeParallelDSM(ParallelContext *pcxt)
219219
shm_toc_estimate_chunk(&pcxt->estimator,sizeof(FixedParallelState));
220220
shm_toc_estimate_keys(&pcxt->estimator,1);
221221

222+
/*
223+
* If we manage to reach here while non-interruptible, it's unsafe to
224+
* launch any workers: we would fail to process interrupts sent by them.
225+
* We can deal with that edge case by pretending no workers were
226+
* requested.
227+
*/
228+
if (!INTERRUPTS_CAN_BE_PROCESSED())
229+
pcxt->nworkers=0;
230+
222231
/*
223232
* Normally, the user will have requested at least one worker process, but
224233
* if by chance they have not, we can skip a bunch of things here.

‎src/backend/executor/nodeHashjoin.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,13 @@ void
15161516
ExecHashJoinReInitializeDSM(HashJoinState*state,ParallelContext*cxt)
15171517
{
15181518
intplan_node_id=state->js.ps.plan->plan_node_id;
1519-
ParallelHashJoinState*pstate=
1520-
shm_toc_lookup(cxt->toc,plan_node_id, false);
1519+
ParallelHashJoinState*pstate;
1520+
1521+
/* Nothing to do if we failed to create a DSM segment. */
1522+
if (cxt->seg==NULL)
1523+
return;
1524+
1525+
pstate=shm_toc_lookup(cxt->toc,plan_node_id, false);
15211526

15221527
/*
15231528
* It would be possible to reuse the shared hash table in single-batch

‎src/backend/optimizer/plan/planner.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,6 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
331331
* general; updates and deletes have additional problems especially around
332332
* combo CIDs.)
333333
*
334-
* We don't try to use parallel mode unless interruptible. The leader
335-
* expects ProcessInterrupts() calls to reach HandleParallelMessages().
336-
* Even if we called HandleParallelMessages() another way, starting a
337-
* parallel worker is too delay-prone to be prudent when uncancellable.
338-
*
339334
* For now, we don't try to use parallel mode if we're running inside a
340335
* parallel worker. We might eventually be able to relax this
341336
* restriction, but for now it seems best not to have parallel workers
@@ -346,7 +341,6 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
346341
parse->commandType==CMD_SELECT&&
347342
!parse->hasModifyingCTE&&
348343
max_parallel_workers_per_gather>0&&
349-
INTERRUPTS_CAN_BE_PROCESSED()&&
350344
!IsParallelWorker())
351345
{
352346
/* all the cheap tests pass, so scan the query tree */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp