Skip to content

Commit d75288f

Browse files
committed
Make archiver process an auxiliary process.
This commit changes WAL archiver process so that it's treated as an auxiliary process and can use shared memory. This is an infrastructure patch required for upcoming shared-memory based stats collector patch series. These patch series basically need any processes including archiver that can report the statistics to access to shared memory. Since this patch itself is useful to simplify the code and when users monitor the status of archiver, it's committed separately in advance. This commit simplifies the code for WAL archiving. For example, previously backends need to signal to archiver via postmaster when they notify archiver that there are some WAL files to archive. On the other hand, this commit removes that signal to postmaster and enables backends to notify archier directly using shared latch. Also, as the side of this change, the information about archiver process becomes viewable at pg_stat_activity view. Author: Kyotaro Horiguchi Reviewed-by: Andres Freund, Álvaro Herrera, Julien Rouhaud, Tomas Vondra, Arthur Zakirov, Fujii Masao Discussion: https://postgr.es/m/20180629.173418.190173462.horiguchi.kyotaro@lab.ntt.co.jp
1 parent 0ea71c9 commit d75288f

File tree

11 files changed

+162
-213
lines changed

11 files changed

+162
-213
lines changed

doc/src/sgml/monitoring.sgml

+1
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
935935
<literal>logical replication worker</literal>,
936936
<literal>parallel worker</literal>, <literal>background writer</literal>,
937937
<literal>client backend</literal>, <literal>checkpointer</literal>,
938+
<literal>archiver</literal>,
938939
<literal>startup</literal>, <literal>walreceiver</literal>,
939940
<literal>walsender</literal> and <literal>walwriter</literal>.
940941
In addition, background workers registered by extensions may have

src/backend/access/transam/xlogarchive.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
#include "common/archive.h"
2626
#include "miscadmin.h"
2727
#include "postmaster/startup.h"
28+
#include "postmaster/pgarch.h"
2829
#include "replication/walsender.h"
2930
#include "storage/fd.h"
3031
#include "storage/ipc.h"
3132
#include "storage/lwlock.h"
32-
#include "storage/pmsignal.h"
3333

3434
/*
3535
* Attempt to retrieve the specified file from off-line archival storage.
@@ -491,7 +491,7 @@ XLogArchiveNotify(const char *xlog)
491491

492492
/* Notify archiver that it's got something to do */
493493
if (IsUnderPostmaster)
494-
SendPostmasterSignal(PMSIGNAL_WAKEN_ARCHIVER);
494+
PgArchWakeup();
495495
}
496496

497497
/*

src/backend/bootstrap/bootstrap.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ AuxiliaryProcessMain(int argc, char *argv[])
317317
case StartupProcess:
318318
MyBackendType = B_STARTUP;
319319
break;
320+
case ArchiverProcess:
321+
MyBackendType = B_ARCHIVER;
322+
break;
320323
case BgWriterProcess:
321324
MyBackendType = B_BG_WRITER;
322325
break;
@@ -437,30 +440,29 @@ AuxiliaryProcessMain(int argc, char *argv[])
437440
proc_exit(1); /* should never return */
438441

439442
case StartupProcess:
440-
/* don't set signals, startup process has its own agenda */
441443
StartupProcessMain();
442-
proc_exit(1); /* should never return */
444+
proc_exit(1);
445+
446+
case ArchiverProcess:
447+
PgArchiverMain();
448+
proc_exit(1);
443449

444450
case BgWriterProcess:
445-
/* don't set signals, bgwriter has its own agenda */
446451
BackgroundWriterMain();
447-
proc_exit(1); /* should never return */
452+
proc_exit(1);
448453

449454
case CheckpointerProcess:
450-
/* don't set signals, checkpointer has its own agenda */
451455
CheckpointerMain();
452-
proc_exit(1); /* should never return */
456+
proc_exit(1);
453457

454458
case WalWriterProcess:
455-
/* don't set signals, walwriter has its own agenda */
456459
InitXLOGAccess();
457460
WalWriterMain();
458-
proc_exit(1); /* should never return */
461+
proc_exit(1);
459462

460463
case WalReceiverProcess:
461-
/* don't set signals, walreceiver has its own agenda */
462464
WalReceiverMain();
463-
proc_exit(1); /* should never return */
465+
proc_exit(1);
464466

465467
default:
466468
elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);

0 commit comments

Comments
 (0)