=== Applying patches on top of PostgreSQL commit ID 2af6dd3370677d8b06cf2a9eb62f69ba11e12cab === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Tue Nov 3 06:57:28 UTC 2026 On branch cf/5276 nothing to commit, working tree clean === using 'git am' to apply patch ./v3-0001-InstallXLogFileSegment-vs-concurrent-WAL-flush.patch === Applying: InstallXLogFileSegment() vs concurrent WAL flush Using index info to reconstruct a base tree... M src/backend/access/transam/xlog.c M src/backend/storage/file/fd.c Falling back to patching base and 3-way merge... Auto-merging src/backend/storage/file/fd.c Auto-merging src/backend/access/transam/xlog.c CONFLICT (content): Merge conflict in src/backend/access/transam/xlog.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 InstallXLogFileSegment() vs concurrent WAL flush 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 ./v3-0001-InstallXLogFileSegment-vs-concurrent-WAL-flush.patch === patching file src/backend/access/transam/xlog.c Hunk #1 succeeded at 468 (offset 9 lines). Hunk #2 succeeded at 3341 (offset 110 lines). Hunk #3 succeeded at 3714 (offset 127 lines). Hunk #4 succeeded at 3755 (offset 127 lines). Hunk #5 FAILED at 4946. Hunk #6 FAILED at 4993. Hunk #7 FAILED at 5047. 3 out of 7 hunks FAILED -- saving rejects to file src/backend/access/transam/xlog.c.rej patching file src/backend/storage/file/fd.c Hunk #1 succeeded at 777 (offset 5 lines). Unstaged changes after reset: M src/backend/access/transam/xlog.c M src/backend/storage/file/fd.c Removing src/backend/access/transam/xlog.c.rej === using 'git apply' to apply patch ./v3-0001-InstallXLogFileSegment-vs-concurrent-WAL-flush.patch === Applied patch to 'src/backend/access/transam/xlog.c' with conflicts. Applied patch to 'src/backend/storage/file/fd.c' cleanly. U src/backend/access/transam/xlog.c diff --cc src/backend/access/transam/xlog.c index 8636ad9ab2c,a28a9a5dbea..00000000000 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@@ -5557,36 -4929,77 +5590,81 @@@ XLOGShmemRequest(void *arg /* and the buffers themselves */ size = add_size(size, mul_size(XLOG_BLCKSZ, XLOGbuffers)); - /* - * Note: we don't count ControlFileData, it comes out of the "slop factor" - * added by CreateSharedMemoryAndSemaphores. This lets us use this - * routine again below to compute the actual allocation size. - */ - - return size; + ShmemRequestStruct(.name = "XLOG Ctl", + .size = size, + .ptr = (void **) &XLogCtl, + ); + ShmemRequestStruct(.name = "Control File", + .size = sizeof(ControlFileData), + .ptr = (void **) &ControlFile, + ); } -void -XLOGShmemInit(void) +/* + * XLOGShmemInit - initialize the XLogCtl shared memory area. + */ +static void +XLOGShmemInit(void *arg) { - bool foundCFile, - foundXLog; char *allocptr; int i; ++<<<<<<< ours ++======= + ControlFileData *localControlFile; + XLogSegNo lastKnownInstalledSegno = 0; + + #ifdef WAL_DEBUG + + /* + * Create a memory context for WAL debugging that's exempt from the normal + * "no pallocs in critical section" rule. Yes, that can lead to a PANIC if + * an allocation fails, but wal_debug is not for production use anyway. + */ + if (walDebugCxt == NULL) + { + walDebugCxt = AllocSetContextCreate(TopMemoryContext, + "WAL Debug", + ALLOCSET_DEFAULT_SIZES); + MemoryContextAllowInCriticalSection(walDebugCxt, true); + } + #endif + + + XLogCtl = (XLogCtlData *) + ShmemInitStruct("XLOG Ctl", XLOGShmemSize(), &foundXLog); + + localControlFile = ControlFile; + ControlFile = (ControlFileData *) + ShmemInitStruct("Control File", sizeof(ControlFileData), &foundCFile); + + if (foundCFile || foundXLog) + { + /* both should be present or neither */ + Assert(foundCFile && foundXLog); ++>>>>>>> theirs - /* Initialize local copy of WALInsertLocks */ - WALInsertLocks = XLogCtl->Insert.WALInsertLocks; - - if (localControlFile) - pfree(localControlFile); - return; - } memset(XLogCtl, 0, sizeof(XLogCtlData)); /* * Already have read control file locally, unless in bootstrap mode. Move * contents into shared memory. */ - if (localControlFile) + if (LocalControlFile) { ++<<<<<<< ours + memcpy(ControlFile, LocalControlFile, sizeof(ControlFileData)); + pfree(LocalControlFile); + LocalControlFile = NULL; ++======= + memcpy(ControlFile, localControlFile, sizeof(ControlFileData)); + pfree(localControlFile); + /* + * A decent approximation for the last known installed WAL segment + * number can be the segment in which the checkpoint record resides, + * specially in cases where we have had a clean shutdown. + */ + XLByteToSeg(ControlFile->checkPoint, lastKnownInstalledSegno, wal_segment_size); ++>>>>>>> theirs } /* @@@ -5647,41 -5054,8 +5725,45 @@@ pg_atomic_init_u64(&XLogCtl->logWriteResult, InvalidXLogRecPtr); pg_atomic_init_u64(&XLogCtl->logFlushResult, InvalidXLogRecPtr); pg_atomic_init_u64(&XLogCtl->unloggedLSN, InvalidXLogRecPtr); ++<<<<<<< ours + pg_atomic_init_u64(&XLogCtl->lastChecksumChangeRecPtr, InvalidXLogRecPtr); +} + +/* + * XLOGShmemAttach - re-establish WALInsertLocks pointer after attaching. + */ +static void +XLOGShmemAttach(void *arg) +{ + WALInsertLocks = XLogCtl->Insert.WALInsertLocks; +} + +/* + * Initialize process-local state needed by wal_debug. + * + * This must be called before XLogInsertRecord(). + */ +#ifdef WAL_DEBUG +void +InitWalDebug(void) +{ + /* + * Create a memory context for WAL debugging that's exempt from the normal + * "no pallocs in critical section" rule. Yes, that can lead to a PANIC if + * an allocation fails, but wal_debug is not for production use anyway. + */ + if (walDebugCxt == NULL) + { + walDebugCxt = AllocSetContextCreate(TopMemoryContext, + "WAL Debug", + ALLOCSET_DEFAULT_SIZES); + MemoryContextAllowInCriticalSection(walDebugCxt, true); + } ++======= + pg_atomic_init_u64(&XLogCtl->last_known_installed_segno, lastKnownInstalledSegno); ++>>>>>>> theirs } +#endif /* * This func must be called ONCE on system install. It creates pg_control