mirror of
https://github.com/postgres/postgres.git
synced 2026-03-27 04:44:15 -04:00
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.
This commit is contained in:
parent
4d3d9719d2
commit
462a2f1f01
1 changed files with 2 additions and 1 deletions
|
|
@ -515,7 +515,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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue