Skip site navigation (1) Skip section navigation (2)

Re: corner case about replication and shutdown

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: corner case about replication and shutdown
Date: 2011-04-01 03:12:27
Message-ID: AANLkTimoC+EZrw9U=NGwNydjT=ZN3ZBkMaviOoOmvZ2B@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Fri, Apr 1, 2011 at 4:48 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> I think this problem is harmless in practice since it doesn't happen
>> too often. But
>> that can happen...
>>
>> The simple fix is to change ServerLoop() so that it periodically calls
>> PostmasterStateMachine() while shutdown is running.
>
> One idea I had was to have a backend that changes state from regular
> backend to walsender kick the postmaster in some way - for example by
> writing to a socket the other end of which the postmaster is holding
> open.  Florian suggested that  might be useful anyway as a means of
> detecting when the postmaster has gone belly-up, so maybe we could
> kill two birds with one stone.  That seems like too much rejiggering
> to do this late in the release cycle, though.  But I don't think the
> idea of calling PostmasterStateMachine() periodically is very
> appealing either - that's a significant change in how that code is
> being used now, and even if it doesn't break anything else, it'll
> allow for hangs of up to 60 seconds, which doesn't sound exciting
> either.
>
> The root of this problem in some sense is that we don't distinguish
> between regular backends and backends that haven't yet decided whether
> they are regular backends or walsenders.  But even if we created such
> a distinction it won't fix the problem unless the postmaster somehow
> gets notified of the state change.  And if we have that, then we're
> back to not needing to distinguish.
>
> Anyone have a good idea?

Another simple fix is to make walsender send SIGUSR1 to postmaster
so that it calls PostmasterStateMachine() in sigusr1_handler(), when it
marks itself as walsender. The attached patch does this. Thought?

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment: sigusr1_kicks_state_machine_v1.patch
Description: application/octet-stream (2.1 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Noah MischDate: 2011-04-01 04:56:29
Subject: Re: BUG #5856: pg_attribute.attinhcount is not correct.
Previous:From: Robert HaasDate: 2011-04-01 02:58:05
Subject: Re: cast from integer to money

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group