diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-05-13 09:44:43 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-05-13 10:06:52 +0300 |
commit | 1a99d392c13e457dd02385bdf4da7687eb2be237 (patch) | |
tree | 4a06f769f5b15263b904dbd3c4b23e333e0199ab /src/backend/storage/buffer/bufmgr.c | |
parent | 46f9acd3ef90f744e94f11e3de29255ce65ce610 (diff) |
Fix RBM_ZERO_AND_LOCK mode to not acquire lock on local buffers.
Commit 81c45081 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.
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index c5d36a6f705..f9b881ff690 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -511,7 +511,8 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, * (Note that we cannot use LockBuffer() of LockBufferForCleanup() here, * because they assert that the buffer is already valid.) */ - if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK) + if ((mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK) && + !isLocalBuf) LWLockAcquire(bufHdr->content_lock, LW_EXCLUSIVE); if (isLocalBuf) |