Fix confusion of max_parallel_workers mechanism following crash.
Fix confusion of max_parallel_workers mechanism following crash.

Commit b460f5d6693103076dc554aa7cbb96e1e53074f9 failed to contemplate
the possibilit that a parallel worker registered before a crash would
be unregistered only after the crash; if that happened, we'd end up
with parallel_terminate_count > parallel_register_count and the
system would refuse to launch any more parallel workers.

The easiest way to fix that seems to be to forget BGW_NEVER_RESTART
workers in ResetBackgroundWorkerCrashTimes() rather than leaving them
around to be cleaned up after the conclusion of the restart, so that
they go away before rather than after shared memory is reset.

To make sure that this fix is water-tight, don't allow parallel
workers to be anything other than BGW_NEVER_RESTART, so that after
recovering from a crash, 0 is guaranteed to be the correct starting
value for parallel_register_count.  The core code wouldn't do this
anyway, but somebody might try to do it in extension code.

Report by Thomas Vondra.  Patch by me, reviewed by Kuntal Ghosh.

Discussion: 176d8a522cfaaf7ebded4660dff3a3aae17c75f9@mail.gmail.com

lisakowen/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,lisakowen/gpdb,xinzweb/gpdb,greenplum-db/gpdb,adam8157/gpdb,xinzweb/gpdb,50wu/gpdb,xinzweb/gpdb,xinzweb/gpdb,adam8157/gpdb,lisakowen/gpdb,adam8157/gpdb,adam8157/gpdb,lisakowen/gpdb,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,xinzweb/gpdb,50wu/gpdb,lisakowen/gpdb,50wu/gpdb,50wu/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb,lisakowen/gpdb,xinzweb/gpdb,50wu/gpdb,greenplum-db/gpdb,50wu/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,xinzweb/gpdb,adam8157/gpdb,adam8157/gpdb,50wu/gpdb,adam8157/gpdb