Re: Proposal: Limitations of palloc inside checkpointer
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Xuneng Zhou <xunengzhou@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>,
Maxim Orlov <orlovmg@gmail.com>, Andres Freund <andres@anarazel.de>,
Ekaterina Sokolova <e.sokolova@postgrespro.ru>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-08-06T18:58:34Z
Lists: pgsql-hackers
Alexander Korotkov <aekorotkov@gmail.com> writes:
> I'm going to push this if no objections.
I looked at these patches while preparing release notes, and
found an oversight. CheckpointerShmemInit does
CheckpointerShmem->max_requests = Min(NBuffers, MAX_CHECKPOINT_REQUESTS);
but CheckpointerShmemSize still does
size = add_size(size, mul_size(NBuffers, sizeof(CheckpointerRequest)));
So if NBuffers is more than MAX_CHECKPOINT_REQUESTS, we will allocate
extra CheckpointerRequest array entries that we will never use,
wasting shared memory. Admittedly the amount is small relative to the
shared buffers themselves, but at the very least this is confusing.
The comment in CheckpointerShmemSize needs adjustment, too.
Also, the reason I was studying it so carefully is that I could not
figure out who to credit for the back-patched fix. It looks like
the original suggestion for the minimal fix was Alexander's, but
other people seem to have had their fingers in the actual patch
writing --- or am I misreading the thread?
regards, tom lane
Commits
-
Fix checkpointer shared memory allocation
- 605890034805 17.6 landed
- 7f872ae7020e 13.22 landed
- c5d66fc12b08 14.19 landed
- 73f897ba5836 15.14 landed
- 2ac50f1187c2 16.10 landed
- 5cfbff48a4fd 18.0 landed
- 466c5435fd45 19 (unreleased) landed
-
Limit checkpointer requests queue size
- f32a471612c9 13.22 landed
- 50026136cc86 14.19 landed
- f0cdc2afd15e 16.10 landed
- b248a3ba4e51 15.14 landed
- 13559de95383 17.6 landed
- bae50782170c 18.0 landed
-
Process sync requests incrementally in AbsorbSyncRequests
- 258bf0a2ea8f 19 (unreleased) landed