Commit 74618e77 authored by Thomas Munro's avatar Thomas Munro

Handle lack of DSM slots in parallel btree build.

If no DSM slots are available, a ParallelContext can still be
created, but its seg pointer is NULL.  Teach parallel btree build
to cope with that by falling back to a regular non-parallel build,
to avoid crashing with a segmentation fault.

Back-patch to 11, where parallel CREATE INDEX landed.

Reported-by: Nicola Contu
Reviewed-by: Peter Geoghegan
Discussion: https://postgr.es/m/CA%2BhUKGJgJEBnkuODBVomyK3MWFvDBbMVj%3Dgdt6DnRPU-5sQ6UQ%40mail.gmail.com
parent c9d29775
......@@ -1331,6 +1331,15 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
Assert(request > 0);
pcxt = CreateParallelContext("postgres", "_bt_parallel_build_main",
request);
/* If no DSM segment was available, back out (do serial build) */
if (pcxt->seg == NULL)
{
DestroyParallelContext(pcxt);
ExitParallelMode();
return;
}
scantuplesortstates = leaderparticipates ? request + 1 : request;
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment