Re: Proposal: Limitations of palloc inside checkpointer
Xuneng Zhou <xunengzhou@gmail.com>
From: Xuneng Zhou <xunengzhou@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alexander Korotkov <aekorotkov@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-07T07:16:58Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-checkpointer-shared-memory-allocation.patch (application/octet-stream) patch v1-0001
Hi, Tom! Thanks for catching this. On Thu, Aug 7, 2025 at 2:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > 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. I attached a patch to fix it. Best, Xuneng
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