Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 981524d

Browse files
committed
Make archiver process handle barrier events.
Commit d75288f made WAL archiver process an auxiliary process. An auxiliary process needs to handle barrier events but the commit forgot to make archiver process do that. Reported-by: Thomas Munro Author: Fujii Masao Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA+hUKGLah2w1pWKHonZP_+EQw69=q56AHYwCgEN8GDzsRG_Hgw@mail.gmail.com
1 parent f80979f commit 981524d

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/backend/postmaster/pgarch.c

+27-14
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ static bool pgarch_archiveXlog(char *xlog);
102102
static bool pgarch_readyXlog(char *xlog);
103103
static void pgarch_archiveDone(char *xlog);
104104
static void pgarch_die(int code, Datum arg);
105+
static void HandlePgArchInterrupts(void);
105106

106107
/* Report shared memory space needed by PgArchShmemInit */
107108
Size
@@ -257,12 +258,8 @@ pgarch_MainLoop(void)
257258
/* When we get SIGUSR2, we do one more archive cycle, then exit */
258259
time_to_stop = ready_to_stop;
259260

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();
266263

267264
/*
268265
* If we've gotten SIGTERM, we normally just sit and do nothing until
@@ -355,15 +352,11 @@ pgarch_ArchiverCopyLoop(void)
355352
return;
356353

357354
/*
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.
361358
*/
362-
if (ConfigReloadPending)
363-
{
364-
ConfigReloadPending = false;
365-
ProcessConfigFile(PGC_SIGHUP);
366-
}
359+
HandlePgArchInterrupts();
367360

368361
/* can't do anything if no command ... */
369362
if (!XLogArchiveCommandSet())
@@ -703,3 +696,23 @@ pgarch_die(int code, Datum arg)
703696
{
704697
PgArch->pgprocno = INVALID_PGPROCNO;
705698
}
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

Comments
 (0)