=== Applying patches on top of PostgreSQL commit ID 3a36543d7d08eef6496fe3511f4cf04cba14f572 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Fri Oct 10 15:19:20 UTC 2025 On branch cf/6023 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Instrumentation-Keep-time-fields-as-instrtime-req.patch === Applying: Instrumentation: Keep time fields as instrtime, require caller to convert === using 'git am' to apply patch ./v2-0002-Separate-node-instrumentation-from-other-use-of-I.patch === Applying: Separate node instrumentation from other use of Instrumentation struct === using 'git am' to apply patch ./v2-0003-Replace-direct-changes-of-pgBufferUsage-pgWalUsag.patch === Applying: Replace direct changes of pgBufferUsage/pgWalUsage with INSTR_* macros Using index info to reconstruct a base tree... M src/backend/access/transam/xlog.c M src/backend/storage/buffer/bufmgr.c Falling back to patching base and 3-way merge... Auto-merging src/backend/storage/buffer/bufmgr.c CONFLICT (content): Merge conflict in src/backend/storage/buffer/bufmgr.c Auto-merging 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 Replace direct changes of pgBufferUsage/pgWalUsage with INSTR_* macros 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". Unstaged changes after reset: M src/backend/access/transam/xlog.c M src/backend/storage/buffer/bufmgr.c M src/backend/storage/buffer/localbuf.c M src/backend/storage/file/buffile.c M src/backend/utils/activity/pgstat_io.c M src/include/executor/instrument.h === using patch(1) to apply patch ./v2-0003-Replace-direct-changes-of-pgBufferUsage-pgWalUsag.patch === patching file src/backend/access/transam/xlog.c patching file src/backend/storage/buffer/bufmgr.c Hunk #1 succeeded at 706 (offset 1 line). Hunk #2 FAILED at 737. Hunk #3 succeeded at 1134 (offset -13 lines). Hunk #4 succeeded at 1875 (offset -13 lines). Hunk #5 succeeded at 1945 (offset -13 lines). Hunk #6 succeeded at 2824 (offset -18 lines). Hunk #7 succeeded at 2980 (offset 20 lines). Hunk #8 succeeded at 4399 (offset 31 lines). Hunk #9 succeeded at 5562 (offset 38 lines). 1 out of 9 hunks FAILED -- saving rejects to file src/backend/storage/buffer/bufmgr.c.rej patching file src/backend/storage/buffer/localbuf.c patching file src/backend/storage/file/buffile.c patching file src/backend/utils/activity/pgstat_io.c patching file src/include/executor/instrument.h Unstaged changes after reset: M src/backend/access/transam/xlog.c M src/backend/storage/buffer/bufmgr.c M src/backend/storage/buffer/localbuf.c M src/backend/storage/file/buffile.c M src/backend/utils/activity/pgstat_io.c M src/include/executor/instrument.h Removing src/backend/storage/buffer/bufmgr.c.rej === using 'git apply' to apply patch ./v2-0003-Replace-direct-changes-of-pgBufferUsage-pgWalUsag.patch === Applied patch to 'src/backend/access/transam/xlog.c' cleanly. Applied patch to 'src/backend/storage/buffer/bufmgr.c' with conflicts. Applied patch to 'src/backend/storage/buffer/localbuf.c' cleanly. Applied patch to 'src/backend/storage/file/buffile.c' cleanly. Applied patch to 'src/backend/utils/activity/pgstat_io.c' cleanly. Applied patch to 'src/include/executor/instrument.h' cleanly. U src/backend/storage/buffer/bufmgr.c diff --cc src/backend/storage/buffer/bufmgr.c index edf17ce3ea1,d872d9efb93..00000000000 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@@ -714,24 -713,38 +714,40 @@@ ReadRecentBuffer(RelFileLocator rlocato else { bufHdr = GetBufferDescriptor(recent_buffer - 1); - have_private_ref = GetPrivateRefCount(recent_buffer) > 0; /* - * Do we already have this buffer pinned with a private reference? If - * so, it must be valid and it is safe to check the tag without - * locking. If not, we have to lock the header first and then check. + * Is it still valid and holding the right tag? We do an unlocked tag + * comparison first, to make it unlikely that we'll increment the + * usage counter of the wrong buffer, if someone calls us with a very + * out of date recent_buffer. Then we'll check it again if we get the + * pin. */ - if (have_private_ref) - buf_state = pg_atomic_read_u32(&bufHdr->state); - else - buf_state = LockBufHdr(bufHdr); - - if ((buf_state & BM_VALID) && BufferTagsEqual(&tag, &bufHdr->tag)) + if (BufferTagsEqual(&tag, &bufHdr->tag) && + PinBuffer(bufHdr, NULL, true)) { ++<<<<<<< ours + if (BufferTagsEqual(&tag, &bufHdr->tag)) + { + pgBufferUsage.shared_blks_hit++; + return true; + } + UnpinBuffer(bufHdr); ++======= + /* + * It's now safe to pin the buffer. We can't pin first and ask + * questions later, because it might confuse code paths like + * InvalidateBuffer() if we pinned a random non-matching buffer. + */ + if (have_private_ref) + PinBuffer(bufHdr, NULL); /* bump pin count */ + else + PinBuffer_Locked(bufHdr); /* pin for first time */ + + INSTR_BUFUSAGE_INCR(shared_blks_hit); + + return true; ++>>>>>>> theirs } - - /* If we locked the header above, now unlock. */ - if (!have_private_ref) - UnlockBufHdr(bufHdr, buf_state); } return false;