Improve fix for not entering parallel mode when holding interrupts.
authorTom Lane <[email protected]>
Fri, 8 Nov 2024 18:42:01 +0000 (13:42 -0500)
committerTom Lane <[email protected]>
Fri, 8 Nov 2024 18:42:01 +0000 (13:42 -0500)
commit6e39ca6e7edb97e12274607e285b6a4262b94af9
treedd9c85b4e8000d2a13b309d4dc21c4d3e2fd56c1
parent9c4757491683a10f0531bd206850d15dad8cadeb
Improve fix for not entering parallel mode when holding interrupts.

Commit ac04aa84a put the shutoff for this into the planner, which is
not ideal because it doesn't prevent us from re-using a previously
made parallel plan.  Revert the planner change and instead put the
shutoff into InitializeParallelDSM, modeling it on the existing code
there for recovering from failure to allocate a DSM segment.

However, that code path is mostly untested, and testing a bit harder
showed there's at least one bug: ExecHashJoinReInitializeDSM is not
prepared for us to have skipped doing parallel DSM setup.  I also
thought the Assert in ReinitializeParallelWorkers is pretty
ill-advised, and replaced it with a silent Min() operation.

The existing test case added by ac04aa84a serves fine to test this
version of the fix, so no change needed there.

Patch by me, but thanks to Noah Misch for the core idea that we
could shut off worker creation when !INTERRUPTS_CAN_BE_PROCESSED.
Back-patch to v12, as ac04aa84a was.

Discussion: https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com
src/backend/access/transam/parallel.c
src/backend/executor/nodeHashjoin.c
src/backend/optimizer/plan/planner.c