pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix crash in autoprewarm.
Date: Tue, 23 Jan 2024 20:22:14 +0000
Message-ID: <E1rSNHi-002mSC-Q9@gemulon.postgresql.org> (raw)

Fix crash in autoprewarm.

Commit abb0b4fc03 moved the shared state for autoprewarm to a
dynamic shared memory (DSM) segment, but it left apw_detach_shmem()
in the on_shmem_exit callback list for the autoprewarm leader
process.  This is a problem because shmem_exit() detaches all the
DSM segments prior to calling the on_shmem_exit callbacks, thus
producing segfaults in the exit path for the autoprewarm leader
process.

To fix, move apw_detach_shmem() to the before_shmem_exit callback
list.  This commit also adds a check to pg_prewarm's test that the
server shut down normally.  It might be worth making this a common
check for all shutdowns in TAP tests, but that is left as a future
exercise.

Reported-by: Andres Freund
Reviewed-by: Andres Freund, Álvaro Herrera
Discussion: https://postgr.es/m/20240122204117.swton324xcoodnyi%40awork3.anarazel.de

Branch
------
master

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

Modified Files
--------------
contrib/pg_prewarm/autoprewarm.c  | 10 ++++++++--
contrib/pg_prewarm/t/001_basic.pl |  6 ++++++
2 files changed, 14 insertions(+), 2 deletions(-)



Message-ID: <E1rSNHi-002mSC-Q9@gemulon.postgresql.org>
Permalink:  ../E1rSNHi-002mSC-Q9@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rSNHi-002mSC-Q9@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix crash in autoprewarm.
  In-Reply-To: <E1rSNHi-002mSC-Q9@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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