From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid potential spinlock in a signal handler as part of global b
Date: Wed, 17 Jun 2020 19:47:41 +0000
Message-ID: <E1jle29-0005CY-Dj@gemulon.postgresql.org> (raw)
Avoid potential spinlock in a signal handler as part of global barriers.
On platforms without support for 64bit atomic operations where we also
cannot rely on 64bit reads to have single copy atomicity, such atomics
are implemented using a spinlock based fallback. That means it's not
safe to even read such atomics from within a signal handler (since the
signal handler might run when the spinlock already is held).
To avoid this issue defer global barrier processing out of the signal
handler. Instead of checking local / shared barrier generation to
determine whether to set ProcSignalBarrierPending, introduce
PROCSIGNAL_BARRIER and always set ProcSignalBarrierPending when
receiving such a signal. Additionally avoid redundant work in
ProcessProcSignalBarrier if ProcSignalBarrierPending is unnecessarily.
Also do a small amount of other polishing.
Author: Andres Freund
Reviewed-By: Robert Haas
Discussion: https://postgr.es/m/20200609193723.eu5ilsjxwdpyxhgz@alap3.anarazel.de
Backpatch: 13-, where the code was introduced.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/fd49d53807575e009f7b66771d48c9356344d7d1
Modified Files
--------------
src/backend/storage/ipc/procsignal.c | 87 +++++++++++++++++++++---------------
src/include/storage/procsignal.h | 1 +
2 files changed, 52 insertions(+), 36 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de
Subject: Re: pgsql: Avoid potential spinlock in a signal handler as part of global b
In-Reply-To: <E1jle29-0005CY-Dj@gemulon.postgresql.org>
References: <E1jle29-0005CY-Dj@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox