summaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/bufmgr.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-04-07 15:20:30 -0400
committerAndres Freund <andres@anarazel.de>2025-04-07 15:20:30 -0400
commit8ab4241b9f4f73f2168bcaebc990f8b0a6b7bc81 (patch)
tree5a7bed3f3ca0c8ef6df4b9c1b4b0ef10eeab3404 /src/backend/storage/buffer/bufmgr.c
parenta13d49014dea39bbe436fd6c28fc65f927038ed7 (diff)
localbuf: Add Valgrind buffer access instrumentation
This mirrors 1e0dfd166b3 (+ 46ef520b9566), for temporary table buffers. This is mainly interesting right now because the AIO work currently triggers spurious valgrind errors, and the fix for that is cleaner if temp buffers behave the same as shared buffers. This requires one change beyond the annotations themselves, namely to pin local buffers while writing them out in FlushRelationBuffers(). Reviewed-by: Noah Misch <noah@leadboat.com> Co-authored-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/3pd4322mogfmdd5nln3zphdwhtmq3rzdldqjwb2sfqzcgs22lf@ok2gletdaoe6
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r--src/backend/storage/buffer/bufmgr.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index ffaca5ee54d..5da121872f4 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -4895,8 +4895,21 @@ FlushRelationBuffers(Relation rel)
errcallback.previous = error_context_stack;
error_context_stack = &errcallback;
+ /* Make sure we can handle the pin */
+ ReservePrivateRefCountEntry();
+ ResourceOwnerEnlarge(CurrentResourceOwner);
+
+ /*
+ * Pin/upin mostly to make valgrind work, but it also seems
+ * like the right thing to do.
+ */
+ PinLocalBuffer(bufHdr, false);
+
+
FlushLocalBuffer(bufHdr, srel);
+ UnpinLocalBuffer(BufferDescriptorGetBuffer(bufHdr));
+
/* Pop the error context stack */
error_context_stack = errcallback.previous;
}