Re: Changing shared_buffers without restart
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>, pgsql-hackers@postgresql.org, Jack Ng <Jack.Ng@huawei.com>, Ni Ku <jakkuniku@gmail.com>
Date: 2025-07-02T12:35:37Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove PG_MMAP_FLAGS from mem.h
- c100340729b6 19 (unreleased) landed
-
Improve runtime and output of tests for replication slots checkpointing.
- 4464fddf7b50 18.0 cited
-
Revert support for improved tracking of nested queries
- f85f6ab051b7 18.0 cited
-
Use exported symbols list on macOS for loadable modules as well
- 3feff3916ee1 18.0 cited
-
Add support for basic NUMA awareness
- 65c298f61fc7 18.0 cited
-
Avoid unnecessary copying of a string in pg_restore.c
- 5e1915439085 18.0 cited
-
aio: Infrastructure for io_method=worker
- 55b454d0e140 18.0 cited
-
Improve InitShmemAccess() prototype
- 2a7b2d97171d 18.0 landed
Attachments
- unitialized_variable_warning.patch.txt (text/plain)
Hi Dmitry, Thanks for sharing the patches. On Fri, Jun 20, 2025 at 3:49 PM Dmitry Dolgov <9erthalion6@gmail.com> wrote: > 3. Shared memory shrinking > > So far only shared memory increase was implemented. These patches from Ashutosh > support shrinking as well, which is tricky due to the need for buffer eviction. > > * Support shrinking shared buffers > * Reinitialize StrategyControl after resizing buffers This applies to both shrinking and expansion of shared buffers. When expanding we need to add the new buffers to the freelist by changing next pointer of last buffer in the free list to point to the first new buffer. > * Additional validation for buffer in the ring > > > 0009 adds support to shrink shared buffers. It has two changes: a. > > evict the buffers outside the new buffer size b. remove buffers with > > buffer id outside the new buffer size from the free list. If a buffer > > being evicted is pinned, the operation is aborted and a FATAL error is > > raised. I think we need to change this behaviour to be less severe > > like rolling back the operation or waiting for the pinned buffer to be > > unpinned etc. Better even if we could let users control the behaviour. > > But we need better infrastructure to do such things. That's one TODO > > left in the patch. > > I haven't reviewed those, just tested a bit to finally include into the series. > Note that I had to tweak two things: > > * The way it was originally implemented was sending resize signal to postmaster > before doing eviction, which could result in sigbus when accessing LSN of a > dirty buffer to be evicted. I've reshaped it a bit to make sure eviction always > happens first. Will take a look at this. > > * It seems the CurrentResource owner could be missing sometimes, so I've added > a band-aid checking its presence. > > One side note, during my testing I've noticed assert failures on > pgstat_tracks_io_op inside a wal writer a few times. I couldn't reproduce it > after the fixes above, but still it may indicate that something is off. E.g. > it's somehow not expected that the wal writer will do buffer eviction IO (from > what I understand, the current shrinking implementation allows that). Yes. I think, we have to find a better way to choose a backend which does the actual work. Eviction can be done in that backend itself. Compiler gives warning about an uninitialized variable, which seems to be a real bug. Fix attached. -- Best Wishes, Ashutosh Bapat