pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Make archiver process an auxiliary process.
6+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2021-06-18 981524d2e3 Make archiver process handle barrier events.
* pgsql: Make archiver process an auxiliary process.
@ 2021-03-15 04:14 Fujii Masao <fujii@postgresql.org>
0 siblings, 1 reply; 6+ messages in thread
From: Fujii Masao @ 2021-03-15 04:14 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d75288fb27b8fe0a926aaab7d75816f091ecdc27
Modified Files
--------------
doc/src/sgml/monitoring.sgml | 1 +
src/backend/access/transam/xlogarchive.c | 4 +-
src/backend/bootstrap/bootstrap.c | 22 +--
src/backend/postmaster/pgarch.c | 239 +++++++++++++------------------
src/backend/postmaster/postmaster.c | 81 +++++------
src/backend/storage/ipc/ipci.c | 2 +
src/include/miscadmin.h | 2 +
src/include/postmaster/pgarch.h | 14 +-
src/include/storage/pmsignal.h | 1 -
src/include/storage/proc.h | 8 +-
src/tools/pgindent/typedefs.list | 1 +
11 files changed, 162 insertions(+), 213 deletions(-)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Make archiver process an auxiliary process.
@ 2021-06-12 10:36 Thomas Munro <thomas.munro@gmail.com>
parent: Fujii Masao <fujii@postgresql.org>
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Munro @ 2021-06-12 10:36 UTC (permalink / raw)
To: Fujii Masao <fujii@postgresql.org>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
On Mon, Mar 15, 2021 at 5:14 PM Fujii Masao <fujii@postgresql.org> wrote:
> 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.
I think this needs to handle ProcSignalBarrierPending. Otherwise,
code that tries to use proc signal barriers (like CF #2962 and #2602)
might hang forever when an archiver is running.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Make archiver process an auxiliary process.
@ 2021-06-16 04:29 Fujii Masao <masao.fujii@oss.nttdata.com>
parent: Thomas Munro <thomas.munro@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Fujii Masao @ 2021-06-16 04:29 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; Fujii Masao <fujii@postgresql.org>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
On 2021/06/12 19:36, Thomas Munro wrote:
> On Mon, Mar 15, 2021 at 5:14 PM Fujii Masao <fujii@postgresql.org> wrote:
>> 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.
>
> I think this needs to handle ProcSignalBarrierPending. Otherwise,
> code that tries to use proc signal barriers (like CF #2962 and #2602)
> might hang forever when an archiver is running.
Thanks for the comment! I will investigate this.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Make archiver process an auxiliary process.
@ 2021-06-17 11:28 Fujii Masao <masao.fujii@oss.nttdata.com>
parent: Fujii Masao <masao.fujii@oss.nttdata.com>
0 siblings, 1 reply; 6+ messages in thread
From: Fujii Masao @ 2021-06-17 11:28 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; Fujii Masao <fujii@postgresql.org>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
On 2021/06/16 13:29, Fujii Masao wrote:
>
>
> On 2021/06/12 19:36, Thomas Munro wrote:
>> On Mon, Mar 15, 2021 at 5:14 PM Fujii Masao <fujii@postgresql.org> wrote:
>>> 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.
>>
>> I think this needs to handle ProcSignalBarrierPending. Otherwise,
>> code that tries to use proc signal barriers (like CF #2962 and #2602)
>> might hang forever when an archiver is running.
>
> Thanks for the comment! I will investigate this.
Attached patch changes archiver so that it also handles barrier events.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:
archiver_handles_signal_barrier_v1.patch (text/plain, 2.2K) download
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index dfc7abbc97..74a7d7c4d0 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);
+ }
+}
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Make archiver process an auxiliary process.
@ 2021-06-17 11:32 Thomas Munro <thomas.munro@gmail.com>
parent: Fujii Masao <masao.fujii@oss.nttdata.com>
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Munro @ 2021-06-17 11:32 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@oss.nttdata.com>; +Cc: Fujii Masao <fujii@postgresql.org>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Thu, Jun 17, 2021 at 11:28 PM Fujii Masao
<masao.fujii@oss.nttdata.com> wrote:
> Attached patch changes archiver so that it also handles barrier events.
LGTM. Thanks!
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: Make archiver process an auxiliary process.
@ 2021-06-18 08:58 Fujii Masao <masao.fujii@oss.nttdata.com>
parent: Thomas Munro <thomas.munro@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Fujii Masao @ 2021-06-18 08:58 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; +Cc: Fujii Masao <fujii@postgresql.org>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On 2021/06/17 20:32, Thomas Munro wrote:
> On Thu, Jun 17, 2021 at 11:28 PM Fujii Masao
> <masao.fujii@oss.nttdata.com> wrote:
>> Attached patch changes archiver so that it also handles barrier events.
>
> LGTM. Thanks!
Pushed. Thanks!
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-06-18 08:58 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 04:14 pgsql: Make archiver process an auxiliary process. Fujii Masao <fujii@postgresql.org>
2021-06-12 10:36 ` Thomas Munro <thomas.munro@gmail.com>
2021-06-16 04:29 ` Fujii Masao <masao.fujii@oss.nttdata.com>
2021-06-17 11:28 ` Fujii Masao <masao.fujii@oss.nttdata.com>
2021-06-17 11:32 ` Thomas Munro <thomas.munro@gmail.com>
2021-06-18 08:58 ` Fujii Masao <masao.fujii@oss.nttdata.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox