From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix race condition at backend exit when deleting element in sync
Date: Fri, 01 Nov 2019 13:39:49 +0000
Message-ID: <E1iQX9Z-0008J9-Dm@gemulon.postgresql.org> (raw)
Fix race condition at backend exit when deleting element in syncrep queue
When a backend exits, it gets deleted from the syncrep queue if present.
The queue was checked without SyncRepLock taken in exclusive mode, so it
would have been possible for a backend to remove itself after a WAL
sender already did the job. Fix this issue based on a suggestion from
Fujii Masao, by first checking the queue without the lock. Then, if the
backend is present in the queue, take the lock and perform an additional
lookup check before doing the element deletion.
Author: Dongming Liu
Reviewed-by: Kyotaro Horiguchi, Fujii Masao, Michael Paquier
Discussion: https://postgr.es/m/a0806273-8bbb-43b3-bbe1-c45a58f6ae21.lingce.ldm@alibaba-inc.com
Backpatch-through: 9.4
Branch
------
REL9_4_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/f88f7206edbfe9d06655e3885219d812b0362251
Modified Files
--------------
src/backend/replication/syncrep.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
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: michael@paquier.xyz
Subject: Re: pgsql: Fix race condition at backend exit when deleting element in sync
In-Reply-To: <E1iQX9Z-0008J9-Dm@gemulon.postgresql.org>
References: <E1iQX9Z-0008J9-Dm@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