pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Craig Ringer <craig@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Petr Jelinek <petr@2ndquadrant.com>
Cc: Peter Eisentraut <peter_e@gmx.net>
Subject: Re: walsender & parallelism
Date: Mon, 24 Apr 2017 04:26:16 +0200
Message-ID: <c3f6947b-47eb-a350-5e92-af3c05c3976d@2ndquadrant.com> (raw)
In-Reply-To: <20170423235941.qosiuoyqprq4nu7v@alap3.anarazel.de>
References: <20170421014030.fdzvvvbrz4nckrow@alap3.anarazel.de>
	<e41081d2-080f-b612-2084-549fa652fae2@2ndquadrant.com>
	<CAMsr+YGAKGcAVpEB7Br3yS9GNdB-KEF0LJEpHPiyf7XFnBr2PQ@mail.gmail.com>
	<a6167509-dc9f-411b-3bbd-758ab8079139@2ndquadrant.com>
	<7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@2ndquadrant.com>
	<20170423235941.qosiuoyqprq4nu7v@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 24/04/17 01:59, Andres Freund wrote:
> Hi,
> 
> On 2017-04-22 17:53:19 +0200, Petr Jelinek wrote:
>> Here is patch. I changed both SIGINT and SIGUSR1 handlers, afaics it
>> does not break anything for existing walsender usage.
> 
>> diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
>> index 761fbfa..e9dd886 100644
>> --- a/src/backend/replication/logical/launcher.c
>> +++ b/src/backend/replication/logical/launcher.c
>> @@ -254,7 +254,7 @@ logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid,
>>  	BackgroundWorker	bgw;
>>  	BackgroundWorkerHandle *bgw_handle;
>>  	int					i;
>> -	int					slot;
>> +	int					slot = 0;
>>  	LogicalRepWorker   *worker = NULL;
>>  	int					nsyncworkers = 0;
>>  	TimestampTz			now = GetCurrentTimestamp();
> 
> That seems independent and unnecessary?
> 

Yeah that leaked from different patch I was working on in parallel.

> 
>> -/* SIGUSR1: set flag to send WAL records */
>> -static void
>> -WalSndXLogSendHandler(SIGNAL_ARGS)
>> -{
>> -	int			save_errno = errno;
>> -
>> -	latch_sigusr1_handler();
>> -
>> -	errno = save_errno;
>> -}
> 
>>  	pqsignal(SIGPIPE, SIG_IGN);
>> -	pqsignal(SIGUSR1, WalSndXLogSendHandler);	/* request WAL sending */
>> +	pqsignal(SIGUSR1, procsignal_sigusr1_handler);
> 
> Those aren't actually entirely equivalent. I'm not sure it matters much,
> but WalSndXLogSendHandler didn't include a SetLatch(), but
> procsignal_sigusr1_handler() does.  Normally redundant SetLatch() calls
> will just be elided, but what if walsender already woke up and did it's
> work?
> 

They aren't exactly same no, but I don't see harm in what
procsignal_sigusr1_handler. I mean worst case scenario is latch is set
so walsender checks for work.

> I think it'd be better to have PostgresMain() set up signals by default,
> and then have WalSndSignals() overwrites the ones it needs separate.

Hmm that sounds like a good idea.

> WalSndLastCycleHandler is genuinely different. WalSndSigHupHandler
> currently sets a different variable from postgres.c, but that seems like
> a bad idea, because afaics we'll plainly ignore SIGHUPS unless in
> WalSndLoop, WalSndWriteData,WalSndWaitForWal.  That actually seems like
> an active bug to me?
> 

Hmm I don't think good solution is to use same variable though,
walsender needs to do slightly different thing on SIGHUP, plus the
got_SIGHUP is not the type of variable we want to export. I wonder if it
would be enough to just add check for got_SIGHUP somewhere at the
beginning of exec_replication_command().

-- 
  Petr Jelinek                  http://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (41+ messages)  latest in thread

Message-ID: <c3f6947b-47eb-a350-5e92-af3c05c3976d@2ndquadrant.com>
Permalink:  ../c3f6947b-47eb-a350-5e92-af3c05c3976d@2ndquadrant.com/
Also on:    postgresql.org/message-id/c3f6947b-47eb-a350-5e92-af3c05c3976d@2ndquadrant.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-hackers@postgresql.org
  Cc: petr.jelinek@2ndquadrant.com, andres@anarazel.de, craig@2ndquadrant.com, petr@2ndquadrant.com, peter_e@gmx.net
  Subject: Re: walsender & parallelism
  In-Reply-To: <c3f6947b-47eb-a350-5e92-af3c05c3976d@2ndquadrant.com>
  References: <20170421014030.fdzvvvbrz4nckrow@alap3.anarazel.de> <e41081d2-080f-b612-2084-549fa652fae2@2ndquadrant.com> <CAMsr+YGAKGcAVpEB7Br3yS9GNdB-KEF0LJEpHPiyf7XFnBr2PQ@mail.gmail.com> <a6167509-dc9f-411b-3bbd-758ab8079139@2ndquadrant.com> <7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@2ndquadrant.com> <20170423235941.qosiuoyqprq4nu7v@alap3.anarazel.de> <c3f6947b-47eb-a350-5e92-af3c05c3976d@2ndquadrant.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