]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid stale slot access after dropping obsolete synced slots.
authorAmit Kapila <akapila@postgresql.org>
Thu, 18 Jun 2026 04:05:53 +0000 (09:35 +0530)
committerAmit Kapila <akapila@postgresql.org>
Thu, 18 Jun 2026 04:05:53 +0000 (09:35 +0530)
commitea834d747d454c4fd66b08ebecaa9483476cf4a4
treea0d5909b74882701d9a700b194ee4216894036dd
parent2e0c61aed6241bb66547bfab7467d43f889f78ba
Avoid stale slot access after dropping obsolete synced slots.

drop_local_obsolete_slots() continued to dereference local_slot after
calling ReplicationSlotDropAcquired().  Once the slot is dropped, its
entry in the slot array can be reused by another backend, so later reads
of local_slot->data could observe a different slot's name or database
OID, leading to an incorrect unlock and log message.

Save the slot name and database OID before performing the drop, and use
the saved values for the subsequent UnlockSharedObject() call and the log
message.  While at it, emit the "dropped replication slot" message only
when a slot was actually dropped, rather than unconditionally.

Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Backpatch-through: 17, where it was introduced
Discussion: https://postgr.es/m/TY4PR01MB177184FF9EE916F577E1F554194082@TY4PR01MB17718.jpnprd01.prod.outlook.com
src/backend/replication/logical/slotsync.c