Re: Proposal: Limitations of palloc inside checkpointer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Xuneng Zhou <xunengzhou(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Maxim Orlov <orlovmg(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Ekaterina Sokolova <e(dot)sokolova(at)postgrespro(dot)ru>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: Limitations of palloc inside checkpointer
Date: 2025-08-06 18:58:34
Message-ID: 1439188.1754506714@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexander Korotkov <aekorotkov(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-08-06 19:01:24 Re: fix ancient typo in transformRelOptions()
Previous Message Nathan Bossart 2025-08-06 18:38:38 Re: More protocol.h replacements this time into walsender.c