| From: | Amit Kapila <akapila(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Avoid stale slot access after dropping obsolete synced slots. |
| Date: | 2026-06-18 04:27:19 |
| Message-ID: | E1wa4LX-000opH-0z@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Reviewed-by: Zhijie Hou <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Backpatch-through: 17, where it was introduced
Discussion: https://postgr.es/m/TY4PR01MB177184FF9EE916F577E1F554194082@TY4PR01MB17718.jpnprd01.prod.outlook.com
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ea834d747d454c4fd66b08ebecaa9483476cf4a4
Modified Files
--------------
src/backend/replication/logical/slotsync.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-06-18 05:14:16 | pgsql: Make GetSnapshotData() more resilient on out-of-memory errors |
| Previous Message | Michael Paquier | 2026-06-18 02:50:10 | pgsql: Fix PANIC with track_functions due to concurrent drop of pgstats |