Content-Length: 259750 | pFad | http://github.com/postgrespro/postgres/commit/96b676cc66c5a60a522364487bf7c7a9593bb229

9B Fix RBM_ZERO_AND_LOCK mode to not acquire lock on local buffers. · postgrespro/postgres@96b676c · GitHub
Skip to content

Commit 96b676c

Browse files
committed
Fix RBM_ZERO_AND_LOCK mode to not acquire lock on local buffers.
Commit 81c4508 introduced a new RBM_ZERO_AND_LOCK mode to ReadBuffer, which takes a lock on the buffer before zeroing it. However, you cannot take a lock on a local buffer, and you got a segfault instead. The version of that patch committed to master included a check for !isLocalBuf, and therefore didn't crash, but oddly I missed that in the back-patched versions. This patch adds that check to the back-branches too. RBM_ZERO_AND_LOCK mode is only used during WAL replay, and in hash indexes. WAL replay only deals with shared buffers, so the only way to trigger the bug is with a temporary hash index. Reported by Artem Ignatyev, analysis by Tom Lane.
1 parent 7d09fdf commit 96b676c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
516516
* (Note that we cannot use LockBuffer() of LockBufferForCleanup() here,
517517
* because they assert that the buffer is already valid.)
518518
*/
519-
if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK)
519+
if ((mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK) &&
520+
!isLocalBuf)
520521
LWLockAcquire(bufHdr->content_lock, LW_EXCLUSIVE);
521522

522523
if (isLocalBuf)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/96b676cc66c5a60a522364487bf7c7a9593bb229

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy