=== Applying patches on top of PostgreSQL commit ID 972c14fb9134fdfd76ea6ebcf98a55a945bbc988 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Apr 15 19:19:26 UTC 2026 On branch cf/6192 nothing to commit, working tree clean === using 'git am' to apply patch ./v7-0001-Lock-free-XLog-Reservation-using-lock-free-hash-t.patch === Applying: Lock-free XLog Reservation using lock-free hash-table Using index info to reconstruct a base tree... M src/backend/access/transam/xlog.c M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list 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 Lock-free XLog Reservation using lock-free hash-table 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 ./v7-0001-Lock-free-XLog-Reservation-using-lock-free-hash-t.patch === patching file src/backend/access/transam/xlog.c Hunk #1 succeeded at 69 (offset 1 line). Hunk #2 succeeded at 393 (offset 6 lines). Hunk #3 succeeded at 492 (offset 6 lines). Hunk #4 succeeded at 540 (offset 6 lines). Hunk #5 succeeded at 697 (offset 9 lines). Hunk #6 succeeded at 857 (offset 34 lines). Hunk #7 succeeded at 1263 (offset 38 lines). Hunk #8 succeeded at 1630 (offset 38 lines). Hunk #9 succeeded at 1668 (offset 38 lines). Hunk #10 succeeded at 1695 (offset 38 lines). Hunk #11 succeeded at 2008 (offset 38 lines). Hunk #12 succeeded at 2022 (offset 38 lines). Hunk #13 succeeded at 5780 (offset 383 lines). Hunk #14 FAILED at 5453. Hunk #15 succeeded at 5865 (offset 365 lines). Hunk #16 succeeded at 5891 with fuzz 2 (offset 370 lines). Hunk #17 succeeded at 6921 (offset 383 lines). Hunk #18 succeeded at 8000 (offset 464 lines). Hunk #19 succeeded at 10586 (offset 629 lines). 1 out of 19 hunks FAILED -- saving rejects to file src/backend/access/transam/xlog.c.rej patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 3376 (offset 136 lines). Unstaged changes after reset: M src/backend/access/transam/xlog.c M src/tools/pgindent/typedefs.list Removing src/backend/access/transam/xlog.c.rej === using 'git apply' to apply patch ./v7-0001-Lock-free-XLog-Reservation-using-lock-free-hash-t.patch === Applied patch to 'src/backend/access/transam/xlog.c' with conflicts. Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U src/backend/access/transam/xlog.c diff --cc src/backend/access/transam/xlog.c index f85b5286086,1c9830f89af..00000000000 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@@ -5365,6 -5440,27 +5824,30 @@@ XLOGShmemInit(void *arg } #endif ++<<<<<<< ours ++======= + + 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); + + /* Initialize local copy of WALInsertLocks and PrevLinksHash */ + WALInsertLocks = XLogCtl->Insert.WALInsertLocks; + PrevLinksHash = XLogCtl->Insert.PrevLinksHash; + + if (localControlFile) + pfree(localControlFile); + return; + } ++>>>>>>> theirs memset(XLogCtl, 0, sizeof(XLogCtlData)); /* @@@ -5424,28 -5522,26 +5910,44 @@@ XLogCtl->InstallXLogFileSegmentActive = false; XLogCtl->WalWriterSleeping = false; ++<<<<<<< ours + /* Use the checksum info from control file */ + XLogCtl->data_checksum_version = ControlFile->data_checksum_version; + + SetLocalDataChecksumState(XLogCtl->data_checksum_version); + + SpinLockInit(&XLogCtl->Insert.insertpos_lck); ++======= ++>>>>>>> theirs SpinLockInit(&XLogCtl->info_lck); pg_atomic_init_u64(&XLogCtl->logInsertResult, InvalidXLogRecPtr); pg_atomic_init_u64(&XLogCtl->logWriteResult, InvalidXLogRecPtr); pg_atomic_init_u64(&XLogCtl->logFlushResult, InvalidXLogRecPtr); pg_atomic_init_u64(&XLogCtl->unloggedLSN, InvalidXLogRecPtr); + + pg_atomic_init_u64(&XLogCtl->Insert.CurrBytePos, 0); + + for (i = 0; i < PREV_LINKS_HASH_CAPA; i++) + { + #if WAL_LINK_64 + pg_atomic_init_u64(&PrevLinksHash[i].CurrPos, 0); + pg_atomic_init_u64(&PrevLinksHash[i].PrevPos, WAL_PREV_EMPTY); + #else + pg_atomic_init_u32(&PrevLinksHash[i].CurrPosId, 0); + pg_atomic_init_u32(&PrevLinksHash[i].PrevSize, 0); + #endif + } } +/* + * XLOGShmemAttach - re-establish WALInsertLocks pointer after attaching. + */ +static void +XLOGShmemAttach(void *arg) +{ + WALInsertLocks = XLogCtl->Insert.WALInsertLocks; +} + /* * This func must be called ONCE on system install. It creates pg_control * and the initial XLOG segment. @@@ -7513,15 -7535,9 +8020,15 @@@ CreateCheckPoint(int flags checkPoint.fullPageWrites = Insert->fullPageWrites; checkPoint.wal_level = wal_level; + /* + * Get the current data_checksum_version value from xlogctl, valid at the + * time of the checkpoint. + */ + checkPoint.dataChecksumState = XLogCtl->data_checksum_version; + if (shutdown) { - XLogRecPtr curInsert = XLogBytePosToRecPtr(Insert->CurrBytePos); + XLogRecPtr curInsert = XLogBytePosToRecPtr(ReadInsertCurrBytePos()); /* * Compute new REDO record ptr = location of next XLOG record. @@@ -10107,32 -9958,9 +10614,25 @@@ register_persistent_abort_backup_handle XLogRecPtr GetXLogInsertRecPtr(void) { - XLogCtlInsert *Insert = &XLogCtl->Insert; - uint64 current_bytepos; - - SpinLockAcquire(&Insert->insertpos_lck); - current_bytepos = Insert->CurrBytePos; - SpinLockRelease(&Insert->insertpos_lck); - - return XLogBytePosToRecPtr(current_bytepos); + return XLogBytePosToRecPtr(ReadInsertCurrBytePos()); } +/* + * Get latest WAL record end pointer + */ +XLogRecPtr +GetXLogInsertEndRecPtr(void) +{ + XLogCtlInsert *Insert = &XLogCtl->Insert; + uint64 current_bytepos; + + SpinLockAcquire(&Insert->insertpos_lck); + current_bytepos = Insert->CurrBytePos; + SpinLockRelease(&Insert->insertpos_lck); + + return XLogBytePosToEndRecPtr(current_bytepos); +} + /* * Get latest WAL write pointer */