pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix backend state after a failed after-startup shmem request
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix backend state after a failed after-startup shmem request
@ 2026-08-28 14:58  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 2+ messages in thread

From: Heikki Linnakangas @ 2026-08-28 14:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backend state after a failed after-startup shmem request

RegisterShmemCallbacks() left the backend in a bad state, if an error
occurred in the callbacks or if an allocation failed.  Firstly,
'shmem_request_state' was left in wrong state, causing a subsequent
call to RegisterShmemCallbacks() to wrongly take the postmaster
startup codepath or assertion failures in some other functions.
Secondly, the 'pending_shmem_requests' list was not properly cleaned
up, causing a subsequent RegisterShmemCallbacks() to try to process
the stale, already-freed requests.

To fix, add a PG_TRY() block to clean those things up on error.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAJTYsWVRRWH48=PcuAo_2Y4Ap6M0QRmzxgUfFkNRtdWK74LjBQ@mail.gmail...
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/92d44b200e12c7ecbaee57d37fcd5e8803811358

Modified Files
--------------
src/backend/storage/ipc/shmem.c                    | 74 +++++++++++++++-------
.../modules/test_shmem/t/001_late_shmem_alloc.pl   | 28 ++++++++
src/test/modules/test_shmem/test_shmem.c           | 28 +++++++-
3 files changed, 105 insertions(+), 25 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix backend state after a failed after-startup shmem request
@ 2026-08-28 14:58  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 2+ messages in thread

From: Heikki Linnakangas @ 2026-08-28 14:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix backend state after a failed after-startup shmem request

RegisterShmemCallbacks() left the backend in a bad state, if an error
occurred in the callbacks or if an allocation failed.  Firstly,
'shmem_request_state' was left in wrong state, causing a subsequent
call to RegisterShmemCallbacks() to wrongly take the postmaster
startup codepath or assertion failures in some other functions.
Secondly, the 'pending_shmem_requests' list was not properly cleaned
up, causing a subsequent RegisterShmemCallbacks() to try to process
the stale, already-freed requests.

To fix, add a PG_TRY() block to clean those things up on error.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAJTYsWVRRWH48=PcuAo_2Y4Ap6M0QRmzxgUfFkNRtdWK74LjBQ@mail.gmail...
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c54b6979e033c6182518d4b33feb35771ae738ae

Modified Files
--------------
src/backend/storage/ipc/shmem.c                    | 72 +++++++++++++++-------
.../modules/test_shmem/t/001_late_shmem_alloc.pl   | 28 +++++++++
src/test/modules/test_shmem/test_shmem.c           | 28 ++++++++-
3 files changed, 104 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-08-28 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 14:58 pgsql: Fix backend state after a failed after-startup shmem request Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-08-28 14:58 pgsql: Fix backend state after a failed after-startup shmem request Heikki Linnakangas <heikki.linnakangas@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox