Detach parallel DSM segment after workers have exited

When a parallel worker query fails in the leader while its workers are
still starting up, DestroyParallelContext() requested the termination
of the workers and detached the DSM segment right away, before waiting
for them to exit.  A worker that had not attached to the segment yet
then found it gone and failed with "could not map dynamic shared memory
segment" or some other DSM-related failure, which was confusing.

DestroyParallelContext() now waits for the workers to exit before
detaching the segment.  Such a worker attaches successfully and exits on
the termination request, logging the same message as any other worker
stopped by its leader.

Author: Shihao Zhong <[email protected]>
Discussion: 
https://postgr.es/m/cagrkxqq7d+b+xdcnr0oumg55ej421hpj3sawonu2uc0vkqa...@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f8d8ce3e236d6ba3c786de40c8d62770e7b852aa

Modified Files
--------------
src/backend/access/transam/parallel.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)

Reply via email to