From ccb8ee23306dc4c83eed19a095c475dcf2ab08ee Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Fri, 13 Feb 2026 22:43:14 +0200 Subject: [PATCH] Add get_pin_limit_hook --- src/backend/storage/buffer/bufmgr.c | 3 ++- src/include/storage/bufmgr.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index ff42fb92d69..743557ac3eb 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -66,6 +66,7 @@ #include "utils/resowner.h" #include "utils/timestamp.h" +uint32 (*get_pin_limit_hook)(void); /* Note: these two macros only work on shared buffers, not local ones! */ #define BufHdrGetBlock(bufHdr) ((Block) (BufferBlocks + ((Size) (bufHdr)->buf_id) * BLCKSZ)) @@ -2131,7 +2132,7 @@ LimitAdditionalPins(uint32 *additional_pins) return; max_backends = MaxBackends + NUM_AUXILIARY_PROCS; - max_proportional_pins = NBuffers / max_backends; + max_proportional_pins = get_pin_limit_hook ? get_pin_limit_hook() : NBuffers / max_backends; /* * Subtract the approximate number of buffers already pinned by this diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index a6c2beb06d8..9f3a9a4e247 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -325,6 +325,7 @@ extern int GetAccessStrategyPinLimit(BufferAccessStrategy strategy); extern void FreeAccessStrategy(BufferAccessStrategy strategy); +extern uint32 (*get_pin_limit_hook)(void); /* inline functions */