pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: Craig Ringer <craig@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>
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: Sat, 22 Apr 2017 17:53:19 +0200
Message-ID: <7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@2ndquadrant.com> (raw)
In-Reply-To: <a6167509-dc9f-411b-3bbd-758ab8079139@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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 21/04/17 04:37, Petr Jelinek wrote:
> On 21/04/17 04:32, Craig Ringer wrote:
>> On 21 April 2017 at 10:20, Petr Jelinek <petr.jelinek@2ndquadrant.com> wrote:
>>> On 21/04/17 03:40, Andres Freund wrote:
>>>>
>>>> Since [1] walsender (not receiver as commit message says) can execute
>>>> SQL queries.  While doing some testing of [2] I noticed that SQL queries
>>>> in walsender get stuck if parallelism is used - I have not investigated
>>>> why that is yet, but it surely is an issue.  On first blush I'd suspect
>>>> that some signalling is not wired up correctly (cf. am_walsender branches
>>>> in PostgresMain() and such).
>>>
>>> Looks like SIGUSR1 being different is problem here - it's normally used
>>> to . I also noticed that we don't handle SIGINT (query cancel).
>>>
>>> I'll write proper patch but can you try to just use
>>> procsignal_sigusr1_handler for SIGUSR1 in walsender.c to see if it fixes
>>> the issue?
>>
>> That's what my recovery conflicts for logical decoding on standby
>> patch does, FWIW.
>>
>> I haven't found any issues yet..
>>
> 
> Ah I knew I've seen that change somewhere. I thought it was either in my
> patch or master which is why I thought it's working fine already.
> 

Here is patch. I changed both SIGINT and SIGUSR1 handlers, afaics it
does not break anything for existing walsender usage.

-- 
  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

Attachments:

Handle-signals-correctly-in-walsender.patch (text/plain, 2.5K) download From f59218135092bec9a64cf86b75f1f62a0271d448 Mon Sep 17 00:00:00 2001 From: Petr Jelinek <pjmodos@pjmodos.net> Date: Fri, 21 Apr 2017 05:11:30 +0200 Subject: [PATCH] Handle signals correctly in walsender Since we now support SQL queries in walsender, we also need to handle SIGINT for query cancel and SIGUSR1 for IPC. --- src/backend/replication/logical/launcher.c | 2 +- src/backend/replication/walsender.c | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) 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(); diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index b4ce75a..78369ae 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -212,7 +212,6 @@ static struct /* Signal handlers */ static void WalSndSigHupHandler(SIGNAL_ARGS); -static void WalSndXLogSendHandler(SIGNAL_ARGS); static void WalSndLastCycleHandler(SIGNAL_ARGS); /* Prototypes for private functions */ @@ -2830,17 +2829,6 @@ WalSndSigHupHandler(SIGNAL_ARGS) errno = save_errno; } -/* SIGUSR1: set flag to send WAL records */ -static void -WalSndXLogSendHandler(SIGNAL_ARGS) -{ - int save_errno = errno; - - latch_sigusr1_handler(); - - errno = save_errno; -} - /* SIGUSR2: set flag to do a last cycle and shut down afterwards */ static void WalSndLastCycleHandler(SIGNAL_ARGS) @@ -2869,12 +2857,12 @@ WalSndSignals(void) /* Set up signal handlers */ pqsignal(SIGHUP, WalSndSigHupHandler); /* set flag to read config * file */ - pqsignal(SIGINT, SIG_IGN); /* not used */ + pqsignal(SIGINT, StatementCancelHandler); /* query cancel */ pqsignal(SIGTERM, die); /* request shutdown */ pqsignal(SIGQUIT, quickdie); /* hard crash time */ InitializeTimeouts(); /* establishes SIGALRM handler */ pqsignal(SIGPIPE, SIG_IGN); - pqsignal(SIGUSR1, WalSndXLogSendHandler); /* request WAL sending */ + pqsignal(SIGUSR1, procsignal_sigusr1_handler); pqsignal(SIGUSR2, WalSndLastCycleHandler); /* request a last cycle and * shutdown */ -- 2.7.4

view thread (41+ messages)  latest in thread

Message-ID: <7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@2ndquadrant.com>
Permalink:  ../7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@2ndquadrant.com/
Also on:    postgresql.org/message-id/7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@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, craig@2ndquadrant.com, andres@anarazel.de, petr@2ndquadrant.com, peter_e@gmx.net
  Subject: Re: walsender & parallelism
  In-Reply-To: <7966f454-7cd7-2b0c-8b70-cdca9d5a8c97@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>

* 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