Re: [RFC] Should we fix postmaster to avoid slow shutdown? - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [RFC] Should we fix postmaster to avoid slow shutdown?
Date
Msg-id 372a2c70-97e6-75db-f1e3-e3884acfd660@2ndquadrant.com
Whole thread Raw
In response to Re: [RFC] Should we fix postmaster to avoid slow shutdown?  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Responses Re: [RFC] Should we fix postmaster to avoid slow shutdown?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 11/14/16 4:38 AM, Ashutosh Bapat wrote:
> The patch 02_close_listen... closes the listen sockets
> explicitly when it's known that postmaster is going to stop all the
> children and then die. I have tried to see, if there's a possibility
> that it closes the listen sockets but do not actually die, thus
> causing a server which doesn't accept any connections and doesn't die.
> But I have not found that possibility.

I can see the point of this, but I'm not sure whether this is always a
good idea.  Some people "monitor" postgres shutdown with PQping() or by
parsing the error messages that the client gets.  If we just close the
sockets as soon as possible, we lose all communication and can't tell
what's going on anymore.

If your HA system insists that the crashing server be completely shut
down before moving on, then maybe that can be refined somehow instead?

I haven't seen any analysis in this thread of how much of a problem this
really is.  For example, could we keep the socket open longer but reject
connection attempts faster in this state?

This patch only changes the behavior in the case of a crash or an
immediate shutdown, but not for the other shutdown modes.  I don't think
it is good to create different behaviors for different modes.

A long time ago, ClosePostmasterPorts() essentially had the job to close
all postmaster sockets.  Every single call thereof is in fact commented
with /* Close the postmaster's sockets */.  (Ancient postgres code uses
"port" as a more general term for socket or communication port.)  Now it
has accumulated other tasks so it is more of a
ClosePostmasterOnlyResourcesInChild().  So if we were to introduce a
ClosePostmasterSockets() somehow, we should adjust the naming and the
comments so that we don't have two similar-sounding functions with
confusing comments.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [RFC] Should we fix postmaster to avoid slow shutdown?
Next
From: Robert Haas
Date:
Subject: Re: Declarative partitioning - another take