Re: Proposal: Limitations of palloc inside checkpointer - Mailing list pgsql-hackers

From Xuneng Zhou
Subject Re: Proposal: Limitations of palloc inside checkpointer
Date
Msg-id CABPTF7VsfCBh+zRtDfjQ1a=xfL1EKNK_wXiiLsBr-tHv+vf4VA@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: Limitations of palloc inside checkpointer  (Xuneng Zhou <xunengzhou@gmail.com>)
Responses Re: Proposal: Limitations of palloc inside checkpointer
List pgsql-hackers
Hi,

On Thu, Aug 7, 2025 at 3:16 PM Xuneng Zhou <xunengzhou@gmail.com> wrote:
>
> 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.

Sorry for the error in this patch. I forgot to take the min of
NBuffers and MAX_CHECKPOINT_REQUESTS for mem size calculation.
Many thanks to Alexander for correcting and pushing it.



pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Allow REPLICA IDENTITY with CREATE TABLE statement
Next
From: Fabrice Chapuis
Date:
Subject: Issue with logical replication slot during switchover