Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9uu5-00013e-To for pgsql-general@arkaria.postgresql.org; Wed, 01 Nov 2017 15:26:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e9uu5-0005dc-4t for pgsql-general@arkaria.postgresql.org; Wed, 01 Nov 2017 15:26:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9uu4-0005dS-JV for pgsql-general@postgresql.org; Wed, 01 Nov 2017 15:26:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e9uu0-0005UA-OD for pgsql-general@postgresql.org; Wed, 01 Nov 2017 15:26:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vA1FPvsg010395; Wed, 1 Nov 2017 11:25:57 -0400 From: Tom Lane To: Zarko Aleksic cc: "pgsql-general@postgresql.org" Subject: Re: the database system is shutting down - terminating walsender process due to replication timeout In-reply-to: References: Comments: In-reply-to Zarko Aleksic message dated "Mon, 30 Oct 2017 17:35:58 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10393.1509549957.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 01 Nov 2017 11:25:57 -0400 Message-ID: <10394.1509549957@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Zarko Aleksic writes: > I'm looking for a bit of help understanding a particular behavior we are = seeing with our PostgreSQL 9.6. After issuing a service shutdown command wi= th "systemctl stop" on RHEL 7 our PostgreSQL instance started behaving weir= dly. For the first time it wouldn't shutdown so easily / quickly. > From the logs we could see that standby nodes that were trying to connect= were rejected due to database being shutdown. After wal_sender_timeout and= wal_receiver_timeout (default 60s) were reached the database finally shut = down. It seems that walsender process was preventing the shutdown of the ma= ster database - until timeout was reached, a behavior we didn't experience = before. 9.6.what? There were several possibly-relevant bug fixes in 9.6.3 and 9.6.4, notably this one: Author: Tom Lane Branch: master Release: REL_10_BR [fca85f8ef] 2017-06-30 12:00:15 -0400 Branch: REL9_6_STABLE Release: REL9_6_4 [e9d4aa594] 2017-06-30 12:00:03 -04= 00 Branch: REL9_5_STABLE Release: REL9_5_8 [446914f6b] 2017-06-30 12:00:03 -04= 00 Branch: REL9_4_STABLE Release: REL9_4_13 [5aa8db014] 2017-06-30 12:00:03 -0= 400 Fix walsender to exit promptly if client requests shutdown. =20=20=20=20 It's possible for WalSndWaitForWal to be asked to wait for WAL that doe= sn't exist yet. That's fine, in fact it's the normal situation if we're cau= ght up; but when the client requests shutdown we should not keep waiting. The previous coding could wait indefinitely if the source server was id= le. =20=20=20=20 In passing, improve the rather weak comments in this area, and slightly rearrange some related code for better readability. =20=20=20=20 Back-patch to 9.4 where this code was introduced. =20=20=20=20 Discussion: https://postgr.es/m/14154.1498781234@sss.pgh.pa.us I think that would only apply if the walsender's client had tried to disconnect at the same time you were doing the master-server shutdown, but maybe that's what happened. There is still work going on around the walsender timeout, so maybe what you hit is an as-yet-unresolved bug, but in any case you should be keeping up with minor releases. regards, tom lane --=20 Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general