Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcd5b4b

Browse files
Fix crash in autoprewarm.
Commitabb0b4f moved the shared state for autoprewarm to adynamic shared memory (DSM) segment, but it left apw_detach_shmem()in the on_shmem_exit callback list for the autoprewarm leaderprocess. This is a problem because shmem_exit() detaches all theDSM segments prior to calling the on_shmem_exit callbacks, thusproducing segfaults in the exit path for the autoprewarm leaderprocess.To fix, move apw_detach_shmem() to the before_shmem_exit callbacklist. This commit also adds a check to pg_prewarm's test that theserver shut down normally. It might be worth making this a commoncheck for all shutdowns in TAP tests, but that is left as a futureexercise.Reported-by: Andres FreundReviewed-by: Andres Freund, Álvaro HerreraDiscussion:https://postgr.es/m/20240122204117.swton324xcoodnyi%40awork3.anarazel.de
1 parent79b03db commitbcd5b4b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

‎contrib/pg_prewarm/autoprewarm.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,14 @@ autoprewarm_main(Datum main_arg)
164164
if (apw_init_shmem())
165165
first_time= false;
166166

167-
/* Set on-detach hook so that our PID will be cleared on exit. */
168-
on_shmem_exit(apw_detach_shmem,0);
167+
/*
168+
* Set on-detach hook so that our PID will be cleared on exit.
169+
*
170+
* NB: Autoprewarm's state is stored in a DSM segment, and DSM segments
171+
* are detached before calling the on_shmem_exit callbacks, so we must put
172+
* apw_detach_shmem in the before_shmem_exit callback list.
173+
*/
174+
before_shmem_exit(apw_detach_shmem,0);
169175

170176
/*
171177
* Store our PID in the shared memory area --- unless there's already

‎contrib/pg_prewarm/t/001_basic.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@
5555

5656
$node->stop;
5757

58+
# control file should indicate normal shut down
59+
command_like(
60+
['pg_controldata',$node->data_dir() ],
61+
qr/Database cluster state:\s*shut down/,
62+
'cluster shut down normally');
63+
5864
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp