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

Commit33394ee

Browse files
committed
Force to send remaining WAL stats to the stats collector at walwriter exit.
In walwriter's main loop, WAL stats message is only sent if enough timehas passed since last one was sent to reach PGSTAT_STAT_INTERVAL msecs.This is necessary to avoid overloading to the stats collector. But thiscan cause recent WAL stats to be unsent when walwriter exits.To ensure that all the WAL stats are sent, this commit makes walwriterforce to send remaining WAL stats to the collector when it exits becauseof shutdown request. Note that those remaining WAL stats can still beunsent when walwriter exits with non-zero exit code (e.g., FATAL error).This is OK because that walwriter exit leads to server crash andsubsequent recovery discards all the stats. So there is no need to sendremaining stats in that case.Author: Masahiro IkedaReviewed-by: Fujii MasaoDiscussion:https://postgr.es/m/0509ad67b585a5b86a83d445dfa75392@oss.nttdata.com
1 parent43c6662 commit33394ee

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

‎src/backend/postmaster/walwriter.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ intWalWriterFlushAfter = 128;
7878
#defineLOOPS_UNTIL_HIBERNATE50
7979
#defineHIBERNATE_FACTOR25
8080

81+
/* Prototypes for private functions */
82+
staticvoidHandleWalWriterInterrupts(void);
83+
8184
/*
8285
* Main entry point for walwriter process
8386
*
@@ -242,7 +245,8 @@ WalWriterMain(void)
242245
/* Clear any already-pending wakeups */
243246
ResetLatch(MyLatch);
244247

245-
HandleMainLoopInterrupts();
248+
/* Process any signals received recently */
249+
HandleWalWriterInterrupts();
246250

247251
/*
248252
* Do what we're here for; then, if XLogBackgroundFlush() found useful
@@ -272,3 +276,34 @@ WalWriterMain(void)
272276
WAIT_EVENT_WAL_WRITER_MAIN);
273277
}
274278
}
279+
280+
/*
281+
* Interrupt handler for main loops of WAL writer process.
282+
*/
283+
staticvoid
284+
HandleWalWriterInterrupts(void)
285+
{
286+
if (ProcSignalBarrierPending)
287+
ProcessProcSignalBarrier();
288+
289+
if (ConfigReloadPending)
290+
{
291+
ConfigReloadPending= false;
292+
ProcessConfigFile(PGC_SIGHUP);
293+
}
294+
295+
if (ShutdownRequestPending)
296+
{
297+
/*
298+
* Force to send remaining WAL statistics to the stats collector at
299+
* process exit.
300+
*
301+
* Since pgstat_send_wal is invoked with 'force' is false in main loop
302+
* to avoid overloading to the stats collector, there may exist unsent
303+
* stats counters for the WAL writer.
304+
*/
305+
pgstat_send_wal(true);
306+
307+
proc_exit(0);
308+
}
309+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp