Re: Changing shared_buffers without restart

From: Yuhang Qiu <iamqyh(at)gmail(dot)com>
To: Palak Chaturvedi <chaturvedipalak1911(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Heikki Linnakangas <heikki(dot)linnakangas(at)databricks(dot)com>, Haoyu Huang <haoyu(dot)huang(at)databricks(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
Subject: Re: Changing shared_buffers without restart
Date: 2026-09-11 10:56:28
Message-ID: 8E7D0939-ADE1-405A-91D2-0139A6E322B3@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Palak,

> Yes. v20260908-0016 rechecks BM_TAG_VALID under LockBufHdr() and does
> UnlockBufHdr() + continue instead of asserting when the tag was
> cleared concurrently.
>
> Right, that line predates the MADV_REMOVE range fix. Removed it in
> v20260908-0015.

Thanks. 0015 and 0016 LGTM.

I also tested the patches and did some more review.

With shared_buffers=32MB and max_shared_buffers left at its default, parallel
workers fail to start, even without any resize:
FATAL: failed to initialize shared_buffers to 16384
CONTEXT: parallel worker

RestoreGUCState() resets the GUC to its 128MB boot value, which exceeds
MaxNBuffers and fails the check hook.

There is also a performance issue in the grow path:
PGSharedMemoryEnsureAllocated() gets the whole structure's range, rather than
just the added range. Even a small increase makes MADV_POPULATE_WRITE walk the
existing range again, adding overhead for large buffer pools. Could we limit
this to the page-aligned [current_end, new_end), as in the shrink path?

Two minor points:
* check_shared_buffers() allows equality with MaxNBuffers, so "must be less than"
should be "must not exceed".
* In proc.c, "specifid there" should be "specified there".

Some issues raised in earlier reviews remain unaddressed. Could you include a
status list with the next update, separating resolved and unresolved items?
That would help reviewers who are new to the thread or haven't followed it for
a while.

Best regards,
Yuhang Qiu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-09-11 10:58:50 Re: Add a permission check to pg_stat_get_backend_subxact()
Previous Message Hayato Kuroda (Fujitsu) 2026-09-11 10:46:34 RE: [PATCH] Explain what the default output_plugin_libraries do