aboutsummaryrefslogtreecommitdiff
path: root/contrib/pg_prewarm/autoprewarm.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pg_prewarm/autoprewarm.c')
-rw-r--r--contrib/pg_prewarm/autoprewarm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c
index 9ea6c2252ad..06ee21d4963 100644
--- a/contrib/pg_prewarm/autoprewarm.c
+++ b/contrib/pg_prewarm/autoprewarm.c
@@ -164,8 +164,14 @@ autoprewarm_main(Datum main_arg)
if (apw_init_shmem())
first_time = false;
- /* Set on-detach hook so that our PID will be cleared on exit. */
- on_shmem_exit(apw_detach_shmem, 0);
+ /*
+ * Set on-detach hook so that our PID will be cleared on exit.
+ *
+ * NB: Autoprewarm's state is stored in a DSM segment, and DSM segments
+ * are detached before calling the on_shmem_exit callbacks, so we must put
+ * apw_detach_shmem in the before_shmem_exit callback list.
+ */
+ before_shmem_exit(apw_detach_shmem, 0);
/*
* Store our PID in the shared memory area --- unless there's already