v1-0001-Fix-checkpointer-shared-memory-allocation.patch
application/octet-stream
Filename: v1-0001-Fix-checkpointer-shared-memory-allocation.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v1-0001
Subject: Fix checkpointer shared memory allocation
| File | + | − |
|---|---|---|
| src/backend/postmaster/checkpointer.c | 2 | 3 |
From 3d9cb6b21a6e44e892e41cba35dd1caff3f437d1 Mon Sep 17 00:00:00 2001 From: alterego665 <824662526@qq.com> Date: Thu, 7 Aug 2025 15:03:10 +0800 Subject: [PATCH v1] Fix checkpointer shared memory allocation Use MAX_CHECKPOINT_REQUESTS instead of NBuffers in CheckpointerShmemSize to match the actual array size limit set in CheckpointerShmemInit. This prevents wasting shared memory when NBuffers > MAX_CHECKPOINT_REQUESTS. Also fix the comment. --- src/backend/postmaster/checkpointer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index 8490148a47d..8d52b24ed05 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -953,11 +953,10 @@ CheckpointerShmemSize(void) Size size; /* - * Currently, the size of the requests[] array is arbitrarily set equal to - * NBuffers. This may prove too large or small ... + * The size of the requests[] array is capped at MAX_CHECKPOINT_REQUESTS. */ size = offsetof(CheckpointerShmemStruct, requests); - size = add_size(size, mul_size(NBuffers, sizeof(CheckpointerRequest))); + size = add_size(size, mul_size(MAX_CHECKPOINT_REQUESTS, sizeof(CheckpointerRequest))); return size; } -- 2.49.0