Block signals while computing the sleep time in postmaster's main loop.
Block signals while computing the sleep time in postmaster's main loop.

DetermineSleepTime() was previously called without blocked
signals. That's not good, because it allows signal handlers to
interrupt its workings.

DetermineSleepTime() was added in 9.3 with the addition of background
workers (da07a1e856511), where it only read from
BackgroundWorkerList.

Since 9.4, where dynamic background workers were added (7f7485a0cde),
the list is also manipulated in DetermineSleepTime(). That's bad
because the list now can be persistently corrupted if modified by both
a signal handler and DetermineSleepTime().

This was discovered during the investigation of hangs on buildfarm
member anole. It's unclear whether this bug is the source of these
hangs or not, but it's worth fixing either way. I have confirmed that
it can cause crashes.

It luckily looks like this only can cause problems when bgworkers are
actively used.

Discussion: 20140929193733.GB14400@awork2.anarazel.de

Backpatch to 9.3 where background workers were introduced.

50wu/gpdb,zeroae/postgres-xl,ashwinstar/gpdb,50wu/gpdb,oberstet/postgres-xl,ashwinstar/gpdb,ovr/postgres-xl,ashwinstar/gpdb,pavanvd/postgres-xl,jmcatamney/gpdb,xinzweb/gpdb,adam8157/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,lisakowen/gpdb,oberstet/postgres-xl,lisakowen/gpdb,xinzweb/gpdb,xinzweb/gpdb,greenplum-db/gpdb,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,50wu/gpdb,oberstet/postgres-xl,lisakowen/gpdb,techdragon/Postgres-XL,jmcatamney/gpdb,yazun/postgres-xl,oberstet/postgres-xl,xinzweb/gpdb,xinzweb/gpdb,50wu/gpdb,greenplum-db/gpdb,pavanvd/postgres-xl,adam8157/gpdb,techdragon/Postgres-XL,zeroae/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,yazun/postgres-xl,techdragon/Postgres-XL,ashwinstar/gpdb,ashwinstar/gpdb,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,ovr/postgres-xl,xinzweb/gpdb,techdragon/Postgres-XL,techdragon/Postgres-XL,greenplum-db/gpdb,adam8157/gpdb,ashwinstar/gpdb,50wu/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,lisakowen/gpdb,oberstet/postgres-xl,ovr/postgres-xl,yazun/postgres-xl,50wu/gpdb,ovr/postgres-xl,50wu/gpdb,lisakowen/gpdb,jmcatamney/gpdb,yazun/postgres-xl,50wu/gpdb,Postgres-XL/Postgres-XL,lisakowen/gpdb,Postgres-XL/Postgres-XL,greenplum-db/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,zeroae/postgres-xl,adam8157/gpdb,adam8157/gpdb,yazun/postgres-xl,Postgres-XL/Postgres-XL,zeroae/postgres-xl,pavanvd/postgres-xl,jmcatamney/gpdb,adam8157/gpdb,zeroae/postgres-xl,xinzweb/gpdb,ovr/postgres-xl,ashwinstar/gpdb