=== Applying patches on top of PostgreSQL commit ID f0178deecbb56283fda8f4c504c8fe16ce23e1a6 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Aug 6 14:23:33 UTC 2026 On branch cf/6404 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Cascade-sync-rep.patch === Applying: Cascade sync rep Implemented cascaded synchronous replication support. The new SyncRepGetSendingSyncRecPtr function in syncrep.c computes replication status values by aggregating positions from synchronous standbys with local server positions. Furthermore, walsender processes can now prompt walreceiver processes for immediate feedback delivery to upstream replication sources. Using index info to reconstruct a base tree... M src/backend/replication/syncrep.c M src/backend/replication/walreceiver.c M src/backend/replication/walsender.c M src/include/access/xlogdefs.h M src/include/replication/syncrep.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/syncrep.h Auto-merging src/include/access/xlogdefs.h Auto-merging src/backend/replication/walsender.c Auto-merging src/backend/replication/walreceiver.c CONFLICT (content): Merge conflict in src/backend/replication/walreceiver.c Auto-merging src/backend/replication/syncrep.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 Cascade sync rep Implemented cascaded synchronous replication support. The new SyncRepGetSendingSyncRecPtr function in syncrep.c computes replication status values by aggregating positions from synchronous standbys with local server positions. Furthermore, walsender processes can now prompt walreceiver processes for immediate feedback delivery to upstream replication sources. 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 ./v2-0001-Cascade-sync-rep.patch === patching file src/backend/replication/syncrep.c Hunk #1 succeeded at 106 (offset 1 line). Hunk #2 succeeded at 638 (offset 9 lines). Hunk #3 succeeded at 861 (offset 7 lines). Hunk #4 succeeded at 1039 (offset 6 lines). patching file src/backend/replication/walreceiver.c Hunk #1 succeeded at 68 (offset 2 lines). Hunk #2 succeeded at 622 with fuzz 2 (offset 92 lines). Hunk #3 FAILED at 1079. Hunk #4 FAILED at 1127. 2 out of 4 hunks FAILED -- saving rejects to file src/backend/replication/walreceiver.c.rej patching file src/backend/replication/walsender.c Hunk #1 succeeded at 2635 (offset 135 lines). patching file src/include/access/xlogdefs.h Hunk #1 succeeded at 29 with fuzz 1 (offset 1 line). patching file src/include/replication/syncrep.h patching file src/include/replication/walsender_private.h Unstaged changes after reset: M src/backend/replication/syncrep.c M src/backend/replication/walreceiver.c M src/backend/replication/walsender.c M src/include/access/xlogdefs.h M src/include/replication/syncrep.h M src/include/replication/walsender_private.h Removing src/backend/replication/walreceiver.c.rej === using 'git apply' to apply patch ./v2-0001-Cascade-sync-rep.patch === Applied patch to 'src/backend/replication/syncrep.c' cleanly. Applied patch to 'src/backend/replication/walreceiver.c' with conflicts. Applied patch to 'src/backend/replication/walsender.c' cleanly. Applied patch to 'src/include/access/xlogdefs.h' cleanly. Applied patch to 'src/include/replication/syncrep.h' cleanly. Applied patch to 'src/include/replication/walsender_private.h' cleanly. U src/backend/replication/walreceiver.c diff --cc src/backend/replication/walreceiver.c index 61dc6a5588b,54452de125c..00000000000 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@@ -618,17 -527,18 +619,18 @@@ WalReceiverMain(const void *startup_dat ResetLatch(MyLatch); CHECK_FOR_INTERRUPTS(); - if (walrcv->force_reply) + if (walrcv->apply_reply_requested) { /* - * The recovery process has asked us to send apply - * feedback now. Make sure the flag is really set to - * false in shared memory before sending the reply, so - * we don't miss a new request for a reply. + * The recovery or one of walsender processes has + * asked us to send apply feedback now. Make sure the + * flag is really set to false in shared memory before + * sending the reply, so we don't miss a new request + * for a reply. */ - walrcv->force_reply = false; + walrcv->apply_reply_requested = false; pg_memory_barrier(); - XLogWalRcvSendReply(true, false); + XLogWalRcvSendReply(false, false, true); } } if (rc & WL_TIMEOUT) @@@ -1181,23 -1078,16 +1183,31 @@@ XLogWalRcvClose(XLogRecPtr recptr, Time } /* ++<<<<<<< ours + * Send reply message to primary, indicating our current WAL locations and + * time. + * + * The message is sent if 'force' is set, if enough time has passed since the + * last update to reach wal_receiver_status_interval, or if WAL locations have + * advanced since the previous status update. If wal_receiver_status_interval + * is disabled and 'force' is false, this function does nothing. Set 'force' to + * send the message unconditionally. ++======= + * Send reply message to primary, indicating our current WAL locations, oldest + * xmin and the current time. When synchronous replication is enabled, transmit + * the oldest write, flush, and apply positions from the current node and its + * standbys to the primary. If position calculation fails, fall back to + * DefaultSendingLSN. ++>>>>>>> theirs * - * If 'force' is not set, the message is only sent if enough time has - * passed since last status update to reach wal_receiver_status_interval. - * If wal_receiver_status_interval is disabled altogether and 'force' is - * false, this is a no-op. + * Whether WAL locations are considered "advanced" depends on 'checkApply'. + * If 'checkApply' is false, only the write and flush locations are checked. + * This should be used when the call is triggered by write/flush activity + * (e.g., after walreceiver writes or flushes WAL), and avoids the + * apply-location check, which requires a spinlock. If 'checkApply' is true, + * the apply location is also considered. This should be used when the apply + * location is expected to advance (e.g., when the startup process requests + * an apply notification). * * If 'requestReply' is true, requests the server to reply immediately upon * receiving this message. This is used for heartbeats, when approaching @@@ -1243,10 -1130,15 +1253,22 @@@ XLogWalRcvSendReply(bool force, bool re WalRcvComputeNextWakeup(WALRCV_WAKEUP_REPLY, now); /* Construct a new message */ ++<<<<<<< ours + writePtr = LogstreamResult.Write; + flushPtr = LogstreamResult.Flush; + applyPtr = XLogRecPtrIsValid(latestApplyPtr) ? + latestApplyPtr : GetXLogReplayRecPtr(NULL); ++======= + if (SyncRepRequested()) + SyncRepGetSendingSyncRecPtr(&writePtr, &flushPtr, &applyPtr, + LogstreamResult.Write, LogstreamResult.Flush, GetXLogReplayRecPtr(NULL)); + else + { + writePtr = LogstreamResult.Write; + flushPtr = LogstreamResult.Flush; + applyPtr = GetXLogReplayRecPtr(NULL); + } ++>>>>>>> theirs resetStringInfo(&reply_message); pq_sendbyte(&reply_message, PqReplMsg_StandbyStatusUpdate);