]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix race in ReplicationSlotRelease() for ephemeral slots REL_14_STABLE github/REL_14_STABLE
authorFujii Masao <fujii@postgresql.org>
Wed, 3 Jun 2026 09:47:31 +0000 (18:47 +0900)
committerFujii Masao <fujii@postgresql.org>
Wed, 3 Jun 2026 09:47:52 +0000 (18:47 +0900)
commit968c508457b3542387c5ee47426565dd20846ab0
treec95eac17ea9deb7928ae4f991a343ad38731ee1c
parent74d3482f45dd8924579a9e5d10f8b15756e9db24
Fix race in ReplicationSlotRelease() for ephemeral slots

When releasing an ephemeral replication slot, ReplicationSlotRelease()
drops the slot via ReplicationSlotDropAcquired().

However, after dropping the slot, ReplicationSlotRelease() continued
to use its local "slot" pointer, which still referenced the dropped
slot's former shared-memory entry. It could then update fields such as
effective_xmin in that entry.

Once an ephemeral slot has been dropped (via ReplicationSlotDropAcquired()),
its slot array entry can be reused immediately by another backend
creating a new slot. As a result, those updates could corrupt
the state of an unrelated replication slot.

Fix by skipping those shared-memory updates for phemeral slots and
performing them only for non-ephemeral slots, whose shared-memory
entries remain valid after release.

Backpatch to all supported versions.

Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Masao Fujii <masao.fujii@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/TY4PR01MB177184FF9EE916F577E1F554194082@TY4PR01MB17718.jpnprd01.prod.outlook.com
Backpatch-through: 14
src/backend/replication/slot.c