agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix race when logical decoding activation is concurrently interr
Date: Tue, 09 Jun 2026 18:19:49 +0000
Message-ID: <E1wX13F-001lhE-2S@gemulon.postgresql.org> (raw)
Fix race when logical decoding activation is concurrently interrupted.
EnableLogicalDecoding() sets xlog_logical_info to true, emits a
procsignal barrier, sets logical_decoding_enabled to true, and then
writes a WAL record. If the activating backend is interrupted between
these steps, a PG_ENSURE_ERROR_CLEANUP() callback runs to undo the
partial activation.
The previous callback asserted that logical_decoding_enabled was still
false and then cleared xlog_logical_info. Both actions were unsafe
when a second backend was concurrently activating: the peer backend
might have already observed xlog_logical_info as true, set
logical_decoding_enabled to true, and written the activation WAL
record before our callback fired, causing the first backend to hit the
assertion failure.
Fix this by having the abort callback call
RequestDisableLogicalDecoding(), allowing the checkpointer to undo the
partial activation in the same manner as a normal deactivation. This
simplifies the logic by unifying the activation abort and deactivation
paths. While this approach now wakes up the checkpointer when an
activation is interrupted, this should not be a serious issue in
practice since such interruptions are rare.
Add a test case to 051_effective_wal_level.pl.
Reported-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/788B5B8A-BC22-48D8-818E-7B00416CF84E@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/93a3e6839bf8d2e0498291335191b57ddf458b48
Modified Files
--------------
src/backend/replication/logical/logicalctl.c | 69 ++++++++++++++------------
src/test/recovery/t/051_effective_wal_level.pl | 45 ++++++++++++++++-
2 files changed, 81 insertions(+), 33 deletions(-)
Message-ID: <E1wX13F-001lhE-2S@gemulon.postgresql.org>
Permalink: ../E1wX13F-001lhE-2S@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wX13F-001lhE-2S@gemulon.postgresql.org
reply
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix race when logical decoding activation is concurrently interr
In-Reply-To: <E1wX13F-001lhE-2S@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox