=== Applying patches on top of PostgreSQL commit ID 98c41fed6fce927539400bc02974b9cb3184befc === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Tue Oct 6 19:41:34 UTC 2026 On branch cf/6132 nothing to commit, working tree clean === using 'git am' to apply patch ./v1-0001-Resync-logical-replication-slot-after-switchover.patch === Applying: Resync logical replication slot after switchover Using index info to reconstruct a base tree... M src/backend/replication/logical/slotsync.c Falling back to patching base and 3-way merge... Auto-merging src/backend/replication/logical/slotsync.c CONFLICT (content): Merge conflict in src/backend/replication/logical/slotsync.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Resync logical replication slot after switchover When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v1-0001-Resync-logical-replication-slot-after-switchover.patch === patching file src/backend/replication/logical/slotsync.c Hunk #1 succeeded at 445 (offset 104 lines). Hunk #2 succeeded at 460 (offset 104 lines). Hunk #3 succeeded at 484 (offset 104 lines). Hunk #4 succeeded at 500 (offset 104 lines). Hunk #5 FAILED at 457. 1 out of 5 hunks FAILED -- saving rejects to file src/backend/replication/logical/slotsync.c.rej Unstaged changes after reset: M src/backend/replication/logical/slotsync.c Removing src/backend/replication/logical/slotsync.c.rej === using 'git apply' to apply patch ./v1-0001-Resync-logical-replication-slot-after-switchover.patch === Applied patch to 'src/backend/replication/logical/slotsync.c' with conflicts. U src/backend/replication/logical/slotsync.c diff --cc src/backend/replication/logical/slotsync.c index c0403893e23,16e20d43fcd..00000000000 --- a/src/backend/replication/logical/slotsync.c +++ b/src/backend/replication/logical/slotsync.c @@@ -558,21 -455,14 +560,29 @@@ drop_local_obsolete_slots(List *remote_ * locking the database, there is a possibility of a parallel * database drop by the startup process and the creation of a new * slot by the user. This new user-created slot may end up using ++<<<<<<< ours + * the same shared memory as that of 'local_slot'. + * + * Because local_slot still points to a reusable slot-array entry, + * its fields (name, database OID, invalidation state) may already + * describe such a replacement slot by the time we reach here. + * That means the drop decision made by local_sync_slot_required() + * above could have been based on the replacement slot's data, and + * slot_database could refer to an unrelated database. The recheck + * below keeps us from actually dropping a user-created + * replacement slot; the residual risk is confined to this cycle + * (for example, briefly locking an unrelated database) and is + * acceptable because the race is rare and non-fatal. ++======= + * the same shared memory as that of 'local_slot'. Thus check if + * local_slot is still the synced one before performing actual + * drop. Yes, we actually check 'failover', not 'synced', because + * it could have been created on primary which is now a standby. ++>>>>>>> theirs */ + SpinLockAcquire(&local_slot->mutex); - synced_slot = local_slot->in_use && local_slot->data.synced; + synced_slot = local_slot->in_use && (local_slot->data.failover || local_slot->data.synced); SpinLockRelease(&local_slot->mutex); if (synced_slot)