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 1hJw5R-0006T6-6k for pgsql-general@arkaria.postgresql.org; Fri, 26 Apr 2019 08:20:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJw5P-0000L8-Um for pgsql-general@arkaria.postgresql.org; Fri, 26 Apr 2019 08:19:59 +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 1hJw5P-00005C-CI for pgsql-general@lists.postgresql.org; Fri, 26 Apr 2019 08:19:59 +0000 Received: from mail.acrys.com ([2003:51:a036:100::2]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJw5L-0007Gn-Ud for pgsql-general@lists.postgresql.org; Fri, 26 Apr 2019 08:19:58 +0000 Received: from gaia.acrys.com (int-mail-hub.acrys.com [10.0.2.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.acrys.com (Postfix) with ESMTPS id 2E74B1BE517 for ; Fri, 26 Apr 2019 10:19:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.acrys.com 2E74B1BE517 Authentication-Results: Acrys.COM; dkim=pass (1024-bit key) header.d=acrys.com header.i=@acrys.com header.b=WQe0sjnH Received: from [10.0.2.73] (nb-pruy.acrys.com [10.0.2.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by gaia.acrys.com (Postfix) with ESMTPS id 83EA362C7153 for ; Fri, 26 Apr 2019 10:19:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 gaia.acrys.com 83EA362C7153 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acrys.com; s=default; t=1556266789; bh=fOwnJ7Fd2CkscZFn4uuKvnoXfda0rU+9uEMXh7qwunA=; h=Subject:To:References:From:Date:In-Reply-To; b=WQe0sjnH7TiJHVd1JwBx6g//veAMYBcG0WLTDgBqtUlmlpKOngipTHbXyGzsMu2sO gMnJdnhUEZC9go6U/n6HQSEtz+znH3PzkMTX/HxLpOmTB28henkOBUcGvsDP/lv+CN uyg98aUraeLPmcGlq9P/hCa6idotB98wKCECWCCY= X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at gaia.acrys.com Subject: Re: TCP Resets when closing connection opened via SSL To: pgsql-general@lists.postgresql.org References: <95b05f8d-990a-4f15-906f-24a011fc00ed@Spark> <695f797f-b02b-492a-94d3-0d5b4ab7c0a2@Spark> <165ba87e-fa48-4eae-b1f3-f9a831b4890b@Spark> From: Rainer Pruy Organization: Acrys Consult GmbH & Co. KG Message-ID: <824d219b-e921-7d10-1711-51349f64611e@acrys.com> Disposition-Notification-To: Rainer Pruy Date: Fri, 26 Apr 2019 10:19:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <165ba87e-fa48-4eae-b1f3-f9a831b4890b@Spark> Content-Type: multipart/alternative; boundary="------------E3DCE7320A3DA5F2D7DDBD4C" Content-Language: en-US X-Spam-Status: No, score=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gaia.acrys.com X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mail.acrys.com [0.0.0.0]); Fri, 26 Apr 2019 10:19:50 +0200 (CEST) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------E3DCE7320A3DA5F2D7DDBD4C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 26.04.19 09:41, Jānis Pūris wrote: > /Resending the original message without any formatting./ > > Hello, > > I'm trying to do a simple health check for keepalived and other > services via a python script and psycopg2 library. All seems to be all > right, until I close the connection, at which point a packet with TCP > reset is produced. > > This has become very problematic and creates extensive noise in > monitoring. > > It also happens with IntelliJ DataGrip provided Java driver and PHP > drivers. And hence I do not think this is the drivers problem, but PG > instead. > From PG side of things, all seems to be OK > What actual problem you are experiencing? Usually, getting a TCP reset is a normal event on TCP connections not necessarily related to any application level activity. A TCP reset is triggered as soon as a packet is being received on a "closed" connection. Such "late orphaned packet" may e.g. result from an ack for a packet in transit by the time of close. For more detailed information you might look at the exact sequence of packets being exchanged. This way, you might get better insight in what is happening and better information on wether something is going wrong. That you do experience TCP reset only with SSL being involved might just be accidentally or be a consequence of  SSL stack activities. It could even be caused by the way the (SSL) connection is being configured/set-up in the specific case. But nevertheless, it might be perfectly OK for such packets to be generated. So, please re-think why you are considering them problematic in the first place. Regards Rainer --------------E3DCE7320A3DA5F2D7DDBD4C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 26.04.19 09:41, Jānis Pūris wrote:
Resending the original message without any formatting.

Hello,

I'm trying to do a simple health check for keepalived and other services via a python script and psycopg2 library. All seems to be all right, until I close the connection, at which point a packet with TCP reset is produced.

This has become very problematic and creates extensive noise in monitoring.

It also happens with IntelliJ DataGrip provided Java driver and PHP drivers. And hence I do not think this is the drivers problem, but PG instead.


From PG side of things, all seems to be OK

What actual problem you are experiencing?

Usually, getting a TCP reset is a normal event on TCP connections not necessarily related to any application level activity.

A TCP reset is triggered as soon as a packet is being received on a "closed" connection.

Such "late orphaned packet" may e.g. result from an ack for a packet in transit by the time of close.


For more detailed information you might look at the exact sequence of packets being exchanged.

This way, you might get better insight in what is happening and better information on wether something is going wrong.


That you do experience TCP reset only with SSL being involved might just be accidentally or be a

consequence of  SSL stack activities. It could even be caused by the way the (SSL) connection

is being configured/set-up in the specific case.

But nevertheless, it might be perfectly OK for such packets to be generated.

So, please re-think why you are considering them problematic in the first place.


Regards

Rainer

--------------E3DCE7320A3DA5F2D7DDBD4C--