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

Commit57dcc2e

Browse files
committed
Poll postmaster less frequently in recovery.
Since commits9f09529 andf98b847 we don't poll the postmasterpipe at all during crash recovery on Linux and FreeBSD, but on otheroperating systems we were still doing it for every WAL record. Do itless frequently on operating systems where system calls are required, atthe cost of delaying exit a bit after postmaster death. This avoidsexpensive system calls reported to slow down CPU-bound recovery by asmuch as 10-30%.Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/CA%2BhUKGK1607VmtrDUHQXrsooU%3Dap4g4R2yaoByWOOA3m8xevUQ%40mail.gmail.comDiscussion:https://postgr.es/m/7261eb39-0369-f2f4-1bb5-62f3b6083b5e@iki.fi
1 parentde829dd commit57dcc2e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

‎src/backend/postmaster/startup.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
#include"utils/timeout.h"
3535

3636

37+
#ifndefUSE_POSTMASTER_DEATH_SIGNAL
38+
/*
39+
* On systems that need to make a system call to find out if the postmaster has
40+
* gone away, we'll do so only every Nth call to HandleStartupProcInterrupts().
41+
* This only affects how long it takes us to detect the condition while we're
42+
* busy replaying WAL. Latch waits and similar which should react immediately
43+
* through the usual techniques.
44+
*/
45+
#definePOSTMASTER_POLL_RATE_LIMIT 1024
46+
#endif
47+
3748
/*
3849
* Flags set by interrupt handlers for later service in the redo loop.
3950
*/
@@ -134,6 +145,10 @@ StartupRereadConfig(void)
134145
void
135146
HandleStartupProcInterrupts(void)
136147
{
148+
#ifdefPOSTMASTER_POLL_RATE_LIMIT
149+
staticuint32postmaster_poll_count=0;
150+
#endif
151+
137152
/*
138153
* Process any requests or signals received recently.
139154
*/
@@ -151,9 +166,15 @@ HandleStartupProcInterrupts(void)
151166

152167
/*
153168
* Emergency bailout if postmaster has died. This is to avoid the
154-
* necessity for manual cleanup of all postmaster children.
169+
* necessity for manual cleanup of all postmaster children. Do this less
170+
* frequently on systems for which we don't have signals to make that
171+
* cheap.
155172
*/
156-
if (IsUnderPostmaster&& !PostmasterIsAlive())
173+
if (IsUnderPostmaster&&
174+
#ifdefPOSTMASTER_POLL_RATE_LIMIT
175+
postmaster_poll_count++ %POSTMASTER_POLL_RATE_LIMIT==0&&
176+
#endif
177+
!PostmasterIsAlive())
157178
exit(1);
158179

159180
/* Process barrier events */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp