=== Applying patches on top of PostgreSQL commit ID 6678b58d7810b7471f00af66423aecb08f87a32a === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Jun 15 18:48:24 UTC 2026 On branch cf/5894 nothing to commit, working tree clean === using 'git am' to apply patch ./v5-0001-Don-t-keep-closed-WAL-segments-in-page-cache-afte.patch === Applying: Don't keep closed WAL segments in page cache after replay Using index info to reconstruct a base tree... M src/backend/access/transam/xlogrecovery.c M src/backend/replication/slot.c M src/backend/replication/walsender.c M src/include/replication/slot.h M src/include/replication/walsender.h M src/include/replication/walsender_private.h Falling back to patching base and 3-way merge... Auto-merging src/include/replication/walsender_private.h Auto-merging src/include/replication/walsender.h Auto-merging src/include/replication/slot.h Auto-merging src/backend/replication/walsender.c CONFLICT (content): Merge conflict in src/backend/replication/walsender.c Auto-merging src/backend/replication/slot.c CONFLICT (content): Merge conflict in src/backend/replication/slot.c Auto-merging src/backend/access/transam/xlogrecovery.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 Don't keep closed WAL segments in page cache after replay 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 ./v5-0001-Don-t-keep-closed-WAL-segments-in-page-cache-afte.patch === patching file src/backend/access/transam/xlogrecovery.c Hunk #2 succeeded at 3312 (offset -59 lines). patching file src/backend/replication/slot.c Hunk #1 FAILED at 220. Hunk #2 succeeded at 529 (offset 7 lines). Hunk #3 succeeded at 590 (offset 8 lines). Hunk #4 succeeded at 1159 (offset 4 lines). 1 out of 4 hunks FAILED -- saving rejects to file src/backend/replication/slot.c.rej patching file src/backend/replication/walsender.c Hunk #1 succeeded at 3234 (offset 142 lines). Hunk #2 succeeded at 3259 (offset 142 lines). Hunk #3 succeeded at 3930 (offset 232 lines). Hunk #4 FAILED at 3795. 1 out of 4 hunks FAILED -- saving rejects to file src/backend/replication/walsender.c.rej patching file src/include/replication/slot.h Hunk #2 succeeded at 366 (offset -3 lines). patching file src/include/replication/walsender.h Hunk #1 succeeded at 47 (offset -1 lines). patching file src/include/replication/walsender_private.h Unstaged changes after reset: M src/backend/access/transam/xlogrecovery.c M src/backend/replication/slot.c M src/backend/replication/walsender.c M src/include/replication/slot.h M src/include/replication/walsender.h M src/include/replication/walsender_private.h Removing src/backend/replication/slot.c.rej Removing src/backend/replication/walsender.c.rej === using 'git apply' to apply patch ./v5-0001-Don-t-keep-closed-WAL-segments-in-page-cache-afte.patch === Applied patch to 'src/backend/access/transam/xlogrecovery.c' cleanly. Applied patch to 'src/backend/replication/slot.c' with conflicts. Applied patch to 'src/backend/replication/walsender.c' with conflicts. Applied patch to 'src/include/replication/slot.h' cleanly. Applied patch to 'src/include/replication/walsender.h' cleanly. Applied patch to 'src/include/replication/walsender_private.h' cleanly. U src/backend/replication/slot.c U src/backend/replication/walsender.c diff --cc src/backend/replication/slot.c index d7fb9f5a67f,9ea7272df4a..00000000000 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@@ -215,21 -200,39 +215,29 @@@ ReplicationSlotsShmemRequest(void *arg } /* - * Allocate and initialize shared memory for replication slots. + * Initialize shared memory for replication slots. */ -void -ReplicationSlotsShmemInit(void) +static void +ReplicationSlotsShmemInit(void *arg) { - bool found; - - if (max_replication_slots == 0) - return; - - ReplicationSlotCtl = (ReplicationSlotCtlData *) - ShmemInitStruct("ReplicationSlot Ctl", ReplicationSlotsShmemSize(), - &found); - - if (!found) + for (int i = 0; i < max_replication_slots + max_repack_replication_slots; i++) { ++<<<<<<< ours + ReplicationSlot *slot = &ReplicationSlotCtl->replication_slots[i]; ++======= + int i; + + /* First time through, so initialize */ + MemSet(ReplicationSlotCtl, 0, ReplicationSlotsShmemSize()); + pg_atomic_init_u32(&ReplicationSlotCtl->used_replication_slots, 0); ++>>>>>>> theirs - for (i = 0; i < max_replication_slots; i++) - { - ReplicationSlot *slot = &ReplicationSlotCtl->replication_slots[i]; - - /* everything else is zeroed by the memset above */ - slot->active_proc = INVALID_PROC_NUMBER; - SpinLockInit(&slot->mutex); - LWLockInitialize(&slot->io_in_progress_lock, - LWTRANCHE_REPLICATION_SLOT_IO); - ConditionVariableInit(&slot->active_cv); - } + /* everything else is zeroed by the memset above */ + slot->active_proc = INVALID_PROC_NUMBER; + SpinLockInit(&slot->mutex); + LWLockInitialize(&slot->io_in_progress_lock, + LWTRANCHE_REPLICATION_SLOT_IO); + ConditionVariableInit(&slot->active_cv); } } diff --cc src/backend/replication/walsender.c index c931d9b4fa8,13fa279658f..00000000000 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@@ -3990,29 -3766,41 +4000,37 @@@ WalSndShmemRequest(void *arg size = offsetof(WalSndCtlData, walsnds); size = add_size(size, mul_size(max_wal_senders, sizeof(WalSnd))); - - return size; + ShmemRequestStruct(.name = "Wal Sender Ctl", + .size = size, + .ptr = (void **) &WalSndCtl, + ); } -/* Allocate and initialize walsender-related shared memory */ -void -WalSndShmemInit(void) +/* Initialize walsender-related shared memory */ +static void +WalSndShmemInit(void *arg) { - bool found; - int i; - - WalSndCtl = (WalSndCtlData *) - ShmemInitStruct("Wal Sender Ctl", WalSndShmemSize(), &found); + for (int i = 0; i < NUM_SYNC_REP_WAIT_MODE; i++) + dlist_init(&(WalSndCtl->SyncRepQueue[i])); - if (!found) + for (int i = 0; i < max_wal_senders; i++) { - /* First time through, so initialize */ - MemSet(WalSndCtl, 0, WalSndShmemSize()); - - for (i = 0; i < NUM_SYNC_REP_WAIT_MODE; i++) - dlist_init(&(WalSndCtl->SyncRepQueue[i])); - - for (i = 0; i < max_wal_senders; i++) - { - WalSnd *walsnd = &WalSndCtl->walsnds[i]; - - SpinLockInit(&walsnd->mutex); - } + WalSnd *walsnd = &WalSndCtl->walsnds[i]; ++<<<<<<< ours + SpinLockInit(&walsnd->mutex); ++======= + pg_atomic_init_u32(&WalSndCtl->active_wal_senders, 0); + + ConditionVariableInit(&WalSndCtl->wal_flush_cv); + ConditionVariableInit(&WalSndCtl->wal_replay_cv); + ConditionVariableInit(&WalSndCtl->wal_confirm_rcv_cv); ++>>>>>>> theirs } + + ConditionVariableInit(&WalSndCtl->wal_flush_cv); + ConditionVariableInit(&WalSndCtl->wal_replay_cv); + ConditionVariableInit(&WalSndCtl->wal_confirm_rcv_cv); } /*