Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibnRr-00031e-Of for pgsql-general@arkaria.postgresql.org; Mon, 02 Dec 2019 15:17:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ibnRq-0003Xy-El for pgsql-general@arkaria.postgresql.org; Mon, 02 Dec 2019 15:17:14 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibnRq-0003Xr-5A for pgsql-general@lists.postgresql.org; Mon, 02 Dec 2019 15:17:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibnRn-0001Ye-Mh for pgsql-general@lists.postgresql.org; Mon, 02 Dec 2019 15:17:13 +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 xB2FH4hk030007; Mon, 2 Dec 2019 10:17:04 -0500 From: Tom Lane To: David Wheeler cc: "pgsql-general@lists.postgresql.org" , Orapan Sanghirunyaplute , Ross Dougherty Subject: Re: Connection terminated but client didn't realise In-reply-to: <124613C2-A989-48C5-9EC6-A11B5B490748@dgitsystems.com> References: <124613C2-A989-48C5-9EC6-A11B5B490748@dgitsystems.com> Comments: In-reply-to David Wheeler message dated "Mon, 02 Dec 2019 06:41:30 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <30005.1575299824.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 02 Dec 2019 10:17:04 -0500 Message-ID: <30006.1575299824@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Wheeler writes: > We have a query that our system runs nightly to refresh materialised vie= ws. This takes some time to execute (~25 minutes) and then it will usually= return the results to the application and everything is golden. However o= ccasionally we see something like the below, where the query finishes, but= the connection gets unexpectedly closed from Postgres=E2=80=99 perspectiv= e. From the application=E2=80=99s perspective the connection is still aliv= e, and it sits there forever waiting for the result. Is the application remote from the database server? My gut reaction to this type of report is "something timed out the network connection", but there would have to be a router or firewall or the like in between to make that a tenable explanation. If that is the issue, you should be able to fix it by making the server's TCP keepalive settings more aggressive. regards, tom lane