aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2021-06-18 17:57:09 +0900
committerFujii Masao <fujii@postgresql.org>2021-06-18 17:57:09 +0900
commit981524d2e3aa3f28d364c472e34f5386be846811 (patch)
tree3733c2cf70be2eb1a85b087ce5d88e589adeee9e
parentf80979f659d39e238e95444e6752142799428078 (diff)
downloadpostgresql-981524d2e3aa3f28d364c472e34f5386be846811.tar.gz
postgresql-981524d2e3aa3f28d364c472e34f5386be846811.zip
Make archiver process handle barrier events.
Commit d75288fb27 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
-rw-r--r--src/backend/postmaster/pgarch.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index dfc7abbc975..74a7d7c4d0a 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -102,6 +102,7 @@ static bool pgarch_archiveXlog(char *xlog);
static bool pgarch_readyXlog(char *xlog);
static void pgarch_archiveDone(char *xlog);
static void pgarch_die(int code, Datum arg);
+static void HandlePgArchInterrupts(void);
/* Report shared memory space needed by PgArchShmemInit */
Size
@@ -257,12 +258,8 @@ pgarch_MainLoop(void)
/* When we get SIGUSR2, we do one more archive cycle, then exit */
time_to_stop = ready_to_stop;
- /* Check for config update */
- if (ConfigReloadPending)
- {
- ConfigReloadPending = false;
- ProcessConfigFile(PGC_SIGHUP);
- }
+ /* Check for barrier events and config update */
+ HandlePgArchInterrupts();
/*
* If we've gotten SIGTERM, we normally just sit and do nothing until
@@ -355,15 +352,11 @@ pgarch_ArchiverCopyLoop(void)
return;
/*
- * Check for config update. This is so that we'll adopt a new
- * setting for archive_command as soon as possible, even if there
- * is a backlog of files to be archived.
+ * Check for barrier events and config update. This is so that
+ * we'll adopt a new setting for archive_command as soon as
+ * possible, even if there is a backlog of files to be archived.
*/
- if (ConfigReloadPending)
- {
- ConfigReloadPending = false;
- ProcessConfigFile(PGC_SIGHUP);
- }
+ HandlePgArchInterrupts();
/* can't do anything if no command ... */
if (!XLogArchiveCommandSet())
@@ -703,3 +696,23 @@ pgarch_die(int code, Datum arg)
{
PgArch->pgprocno = INVALID_PGPROCNO;
}
+
+/*
+ * Interrupt handler for WAL archiver process.
+ *
+ * This is called in the loops pgarch_MainLoop and pgarch_ArchiverCopyLoop.
+ * It checks for barrier events and config update, but not shutdown request
+ * because how to handle shutdown request is different between those loops.
+ */
+static void
+HandlePgArchInterrupts(void)
+{
+ if (ProcSignalBarrierPending)
+ ProcessProcSignalBarrier();
+
+ if (ConfigReloadPending)
+ {
+ ConfigReloadPending = false;
+ ProcessConfigFile(PGC_SIGHUP);
+ }
+}