Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaqx9-0006Fh-9C for pgsql-general@arkaria.postgresql.org; Wed, 21 Sep 2022 04:03:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaqx7-0004SW-QS for pgsql-general@arkaria.postgresql.org; Wed, 21 Sep 2022 04:03:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaqx7-0004SM-FX for pgsql-general@lists.postgresql.org; Wed, 21 Sep 2022 04:03:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaqx3-0008L8-4L for pgsql-general@lists.postgresql.org; Wed, 21 Sep 2022 04:03:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 28L436T6971598; Wed, 21 Sep 2022 00:03:06 -0400 From: Tom Lane To: Rob Sargent cc: "pgsql-generallists.postgresql.org" Subject: Re: tcp settings In-reply-to: References: <934612.1663716103@sss.pgh.pa.us> Comments: In-reply-to Rob Sargent message dated "Tue, 20 Sep 2022 18:46:15 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <971596.1663732986.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 21 Sep 2022 00:03:06 -0400 Message-ID: <971597.1663732986@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Rob Sargent writes: >> then keepalives aren't necessarily the solution anyway. When is >> this failure occurring ... is it while trying to establish the >> database connection in the first place? Or does it only happen >> if you've left the psql session sit idle for a long while? > Sitting idle for not even a long while. Under half hour I feel would do = it. But I don=E2=80=99t think it times out while I=E2=80=99m =E2=80=9CSQL= ing=E2=80=9D OK, that does sound like something that reducing the keepalive interval could help with. The traditional keepalive timeout is a couple of hours, at least on my Linux box: $ cat /proc/sys/net/ipv4/tcp_keepalive_time 7200 but it sounds like there's something between you and the database server that will forget connections a lot quicker than that. regards, tom lane