Fix RBM_ZERO_AND_LOCK mode to not acquire lock on local buffers.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 13 May 2015 06:44:43 +0000 (09:44 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 13 May 2015 06:54:06 +0000 (09:54 +0300)
commit96b676cc66c5a60a522364487bf7c7a9593bb229
treef60513a5537bb68d115a3cb2b42678dbbf529296
parent7d09fdf82363c3d89ce350058a7a940ee843f048
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.
src/backend/storage/buffer/bufmgr.c