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 1hK1f8-0001CJ-4u for pgsql-general@arkaria.postgresql.org; Fri, 26 Apr 2019 14:17:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hK1f6-0007MZ-NU for pgsql-general@arkaria.postgresql.org; Fri, 26 Apr 2019 14:17:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hK1f6-0007GO-A9 for pgsql-general@lists.postgresql.org; Fri, 26 Apr 2019 14:17:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hK1ez-0006oU-PO for pgsql-general@postgresql.org; Fri, 26 Apr 2019 14:17:11 +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 x3QEH40G031612; Fri, 26 Apr 2019 10:17:04 -0400 From: Tom Lane To: =?utf-8?Q?J=C4=81nis_P=C5=ABris?= cc: pgsql-general@postgresql.org Subject: Re: TCP Resets when closing connection opened via SSL In-reply-to: <695f797f-b02b-492a-94d3-0d5b4ab7c0a2@Spark> References: <95b05f8d-990a-4f15-906f-24a011fc00ed@Spark> <695f797f-b02b-492a-94d3-0d5b4ab7c0a2@Spark> Comments: In-reply-to =?utf-8?Q?J=C4=81nis_P=C5=ABris?= message dated "Fri, 26 Apr 2019 09:34:38 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <31610.1556288224.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 26 Apr 2019 10:17:04 -0400 Message-ID: <31611.1556288224@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =3D?utf-8?Q?J=3DC4=3D81nis_P=3DC5=3DABris?=3D writes: > I'm trying to do a simple health check for keepalived and other services= via a python script and=C2=A0psycopg2=C2=A0library. All seems to be all r= ight, until I close the connection, at which point a packet with TCP reset= is produced. Hm. It's fairly obvious from the postmaster log that the client side is not bothering to close the transaction it started: > 2019-04-23 16:27:45.306 CEST process=3D15615 c=3DBEGIN t=3D0 s=3D5cbf20e= 1.3cff monitoring@127.0.0.1:postgres app=3D[unknown] LOG: duration: 0.095= ms > 2019-04-23 16:27:45.306 CEST process=3D15615 c=3DSELECT t=3D0 s=3D5cbf20= e1.3cff monitoring@127.0.0.1:postgres app=3D[unknown] LOG: duration: 0.23= 4 ms > 2019-04-23 16:27:45.306 CEST process=3D15615 c=3Didle in transaction t=3D= 0 s=3D5cbf20e1.3cff monitoring@127.0.0.1:postgres app=3D[unknown] LOG: di= sconnection: session time: 0:00:00.006 user=3Dmonitoring database=3Dpostgr= es host=3D127.0.0.1 port=3D40797 There's no COMMIT or ROLLBACK to go with the BEGIN, and that's reflected in the fact that the disconnection message shows c=3Didle in transaction. Now, I doubt that would have any impact on the TCP-level session behavior, but it suggests that maybe the client isn't bothering to close the session cleanly either. The RST rather than FIN would then likely be caused by SSL having to do an unclean shutdown. regards, tom lane