]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix ReadRecentBuffer for local buffers.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 25 Jul 2022 05:48:38 +0000 (08:48 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 25 Jul 2022 05:53:27 +0000 (08:53 +0300)
commit3f968b9415045c4f8ae3cd56b5b4a83d1aa27db8
tree384c6a605f9b7b87df456f60f783cc0c695d1e0f
parent31d5354cb148c6aa90014f62d3a4752adeebd51a
Fix ReadRecentBuffer for local buffers.

It incorrectly used GetBufferDescriptor instead of
GetLocalBufferDescriptor, causing it to not find the correct buffer in
most cases, and performing an out-of-bounds memory read in the corner
case that temp_buffers > shared_buffers.

It also bumped the usage-count on the buffer, even if it was
previously pinned. That won't lead to crashes or incorrect results,
but it's different from what the shared-buffer case does, and
different from the usual code in LocalBufferAlloc. Fix that too, and
make the code ordering match LocalBufferAlloc() more closely, so that
it's easier to verify that it's doing the same thing.

Currently, ReadRecentBuffer() is only used with non-temp relations, in
WAL redo, so the broken code is currently dead code. However, it could
be used by extensions.

Backpatch-through: 14
Discussion: https://www.postgresql.org/message-id/2d74b46f-27c9-fb31-7f99-327a87184cc0%40iki.fi
Reviewed-by: Thomas Munro, Zhang Mingli, Richard Guo
src/backend/storage/buffer/bufmgr.c