=== Applying patches on top of PostgreSQL commit ID 80d7f990496b1c7be61d9a00a2635b7d96b96197 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Feb 19 14:04:23 UTC 2025 On branch cf/5511 nothing to commit, working tree clean === applying patch ./v2-0001-Fix-typo-and-grammar-in-comment-introduced-by-6a2.patch Applied patch to 'src/backend/access/transam/xlog.c' with conflicts. U src/backend/access/transam/xlog.c diff --cc src/backend/access/transam/xlog.c index f9bf5ba750,06ead0bb0f..0000000000 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@@ -2139,7 -2179,36 +2139,40 @@@ AdvanceXLInsertBuffer(XLogRecPtr upto, pg_write_barrier(); pg_atomic_write_u64(&XLogCtl->xlblocks[nextidx], NewPageEndPtr); ++<<<<<<< ours + XLogCtl->InitializedUpTo = NewPageEndPtr; ++======= + + /* + * Try to advance XLogCtl->InitializedUpTo. + * + * If the CAS operation failed, then some of previous pages are not + * initialized yet, and this backend gives up. + * + * Since initializer of next page might give up on advancing of + * InitializedUpTo, this backend have to attempt advancing until it + * find page "in the past" or concurrent backend succeeded at + * advancing. When we finish advancing XLogCtl->InitializedUpTo, we + * notify all the waiters with XLogCtl->InitializedUpToCondVar. + */ + while (pg_atomic_compare_exchange_u64(&XLogCtl->InitializedUpTo, &NewPageBeginPtr, NewPageEndPtr)) + { + NewPageBeginPtr = NewPageEndPtr; + NewPageEndPtr = NewPageBeginPtr + XLOG_BLCKSZ; + nextidx = XLogRecPtrToBufIdx(NewPageBeginPtr); + + if (pg_atomic_read_u64(&XLogCtl->xlblocks[nextidx]) != NewPageEndPtr) + { + /* + * Page at nextidx hasn't been initialized yet, so we can't move + * InitializedUpto further. It will be moved by the backend that + * initializes nextidx. + */ + ConditionVariableBroadcast(&XLogCtl->InitializedUpToCondVar); + break; + } + } ++>>>>>>> theirs npages++; }