pgsql: Block signals while computing the sleep time in postmaster's mai

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Block signals while computing the sleep time in postmaster's mai
Date: 2014-10-01 13:34:16
Message-ID: E1XZK2q-0004T2-8q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)GB14400(at)awork2(dot)anarazel(dot)de

Backpatch to 9.3 where background workers were introduced.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/cbd9619aca44c2a1991076325612302118ee6975

Modified Files
--------------
src/backend/postmaster/postmaster.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-10-01 13:43:46 pgsql: Remove num_xloginsert_locks GUC, replace with a #define
Previous Message Andres Freund 2014-10-01 13:34:13 pgsql: Block signals while computing the sleep time in postmaster's mai