pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Thomas Munro <thomas.munro@gmail.com>
To: Fujii Masao <fujii@postgresql.org>
Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
Subject: Re: pgsql: Make archiver process an auxiliary process.
Date: Thu, 17 Jun 2021 20:28:36 +0900
Message-ID: <743dda39-ab93-eca5-65e9-1e6eb33f1668@oss.nttdata.com> (raw)
In-Reply-To: <acb63277-66fc-a181-c735-27eebda575d3@oss.nttdata.com>
References: <E1lLecS-0000kF-TC@gemulon.postgresql.org>
	<CA+hUKGLah2w1pWKHonZP_+EQw69=q56AHYwCgEN8GDzsRG_Hgw@mail.gmail.com>
	<acb63277-66fc-a181-c735-27eebda575d3@oss.nttdata.com>



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); + } +}

view thread (6+ messages)  latest in thread

Message-ID: <743dda39-ab93-eca5-65e9-1e6eb33f1668@oss.nttdata.com>
Permalink:  ../743dda39-ab93-eca5-65e9-1e6eb33f1668@oss.nttdata.com/
Also on:    postgresql.org/message-id/743dda39-ab93-eca5-65e9-1e6eb33f1668@oss.nttdata.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, thomas.munro@gmail.com, fujii@postgresql.org
  Subject: Re: pgsql: Make archiver process an auxiliary process.
  In-Reply-To: <743dda39-ab93-eca5-65e9-1e6eb33f1668@oss.nttdata.com>
  References: <E1lLecS-0000kF-TC@gemulon.postgresql.org> <CA+hUKGLah2w1pWKHonZP_+EQw69=q56AHYwCgEN8GDzsRG_Hgw@mail.gmail.com> <acb63277-66fc-a181-c735-27eebda575d3@oss.nttdata.com> <743dda39-ab93-eca5-65e9-1e6eb33f1668@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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