Re: Changing shared_buffers without restart

From: Palak Chaturvedi <chaturvedipalak1911(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: 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-08-20 09:11:57
Message-ID: CALfch19eG7JX3j0jvXLw7TdH+HOp1ZMacBwMMu07AiPPeNtHhw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hey Ashutosh,
I tracked down a flake in 003_resize_failures (fails
roughly 1 in 5 runs). Two assertions fail at lines 157 and 163:

got: 't' expected: 'f'
log message "failed to expand buffer pool structures" absent

It's a SIGHUP delivery race. The test calls pg_reload_conf() from one
backend, then calls pg_resize_shared_buffers() from a different one
($resizer). When the signal hasn't reached $resizer yet, NBuffersGUC
is still the old shrunk value. resize_shared_buffers_internal() sees
currentNBuffers == targetNBuffers, prints "no need to resize," returns
true, and the injection point never fires.

Server log from a failing run:

06:07:17.885 [514631] SELECT pg_reload_conf()
06:07:17.885 postmaster: received SIGHUP, reloading configuration files
06:07:17.887 [514627] shared buffers are already at 18, no need to resize

As per discussion, attached patch (0009) moves the ALTER SYSTEM +
pg_reload_conf()
before creating the $resizer backend. The new backend picks up the
updated NBuffersGUC on connect. Injection point attachment and all
assertions stay the same. 30/30 clean after the fix.

Thanks,
Palak

Attachment Content-Type Size
v20260817-0009-buffermgr-fix-SIGHUP-race-in-003_resize_failures.patch application/octet-stream 2.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-08-20 09:30:56 Re: Logical replication row filter loses unchanged toasted columns
Previous Message Ashutosh Sharma 2026-08-20 09:10:25 Re: Orphaned Files in PostgreSQL