]> 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:12:56 +0000 (09:42 +0530)
committerAmit Kapila <akapila@postgresql.org>
Thu, 18 Jun 2026 04:12:56 +0000 (09:42 +0530)
commit08458bcaea5bc893c6150cc86adbac259a5d7b36
tree2fb31565b0dc341c335f251dd88b45532d48a30d
parent5cc59834b860ed48d710c1baa9c50c66540c64d0
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