postgresql/src/backend/postmaster
Andres Freund a39e78b710 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 (da07a1e856), where it only read from
BackgroundWorkerList.

Since 9.4, where dynamic background workers were added (7f7485a0cd),
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.
2014-10-01 15:19:40 +02:00
..
autovacuum.c Avoid wholesale autovacuuming when autovacuum is nominally off. 2014-07-30 14:41:35 -04:00
bgworker.c When a background worker exists with code 0, unregister it. 2014-05-07 17:44:42 -04:00
bgwriter.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
checkpointer.c Fix and enhance the assertion of no palloc's in a critical section. 2014-06-30 10:26:00 +03:00
fork_process.c Break out OpenSSL-specific code to separate files. 2014-08-11 11:54:19 +03:00
Makefile Allow background workers to be started dynamically. 2013-07-16 13:02:15 -04:00
pgarch.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
pgstat.c Smooth reporting of commit/rollback statistics. 2014-07-02 15:20:30 -05:00
postmaster.c Block signals while computing the sleep time in postmaster's main loop. 2014-10-01 15:19:40 +02:00
startup.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
syslogger.c Fix unportable setvbuf() usage in initdb. 2014-05-15 15:57:54 -04:00
walwriter.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00