@@ -102,6 +102,7 @@ static bool pgarch_archiveXlog(char *xlog);
102
102
static bool pgarch_readyXlog (char * xlog );
103
103
static void pgarch_archiveDone (char * xlog );
104
104
static void pgarch_die (int code , Datum arg );
105
+ static void HandlePgArchInterrupts (void );
105
106
106
107
/* Report shared memory space needed by PgArchShmemInit */
107
108
Size
@@ -257,12 +258,8 @@ pgarch_MainLoop(void)
257
258
/* When we get SIGUSR2, we do one more archive cycle, then exit */
258
259
time_to_stop = ready_to_stop ;
259
260
260
- /* Check for config update */
261
- if (ConfigReloadPending )
262
- {
263
- ConfigReloadPending = false;
264
- ProcessConfigFile (PGC_SIGHUP );
265
- }
261
+ /* Check for barrier events and config update */
262
+ HandlePgArchInterrupts ();
266
263
267
264
/*
268
265
* If we've gotten SIGTERM, we normally just sit and do nothing until
@@ -355,15 +352,11 @@ pgarch_ArchiverCopyLoop(void)
355
352
return ;
356
353
357
354
/*
358
- * Check for config update. This is so that we'll adopt a new
359
- * setting for archive_command as soon as possible, even if there
360
- * is a backlog of files to be archived.
355
+ * Check for barrier events and config update. This is so that
356
+ * we'll adopt a new setting for archive_command as soon as
357
+ * possible, even if there is a backlog of files to be archived.
361
358
*/
362
- if (ConfigReloadPending )
363
- {
364
- ConfigReloadPending = false;
365
- ProcessConfigFile (PGC_SIGHUP );
366
- }
359
+ HandlePgArchInterrupts ();
367
360
368
361
/* can't do anything if no command ... */
369
362
if (!XLogArchiveCommandSet ())
@@ -703,3 +696,23 @@ pgarch_die(int code, Datum arg)
703
696
{
704
697
PgArch -> pgprocno = INVALID_PGPROCNO ;
705
698
}
699
+
700
+ /*
701
+ * Interrupt handler for WAL archiver process.
702
+ *
703
+ * This is called in the loops pgarch_MainLoop and pgarch_ArchiverCopyLoop.
704
+ * It checks for barrier events and config update, but not shutdown request
705
+ * because how to handle shutdown request is different between those loops.
706
+ */
707
+ static void
708
+ HandlePgArchInterrupts (void )
709
+ {
710
+ if (ProcSignalBarrierPending )
711
+ ProcessProcSignalBarrier ();
712
+
713
+ if (ConfigReloadPending )
714
+ {
715
+ ConfigReloadPending = false;
716
+ ProcessConfigFile (PGC_SIGHUP );
717
+ }
718
+ }
0 commit comments