| From: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix backend state after a failed after-startup shmem request |
| Date: | 2026-08-28 14:58:08 |
| Message-ID: | E1wzy1v-00000002VYp-1Kxe@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)slg01(at)gmail(dot)com>
Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/CAJTYsWVRRWH48=PcuAo_2Y4Ap6M0QRmzxgUfFkNRtdWK74LjBQ@mail.gmail.com
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-08-28 19:13:14 | pgsql: Perform join removal by editing the query's jointree. |
| Previous Message | Bruce Momjian | 2026-08-28 14:05:20 | pgsql: doc PG 19 relnotes: move replication items to logical replicat. |