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 1hKLD2-0006b9-Mm for pgsql-general@arkaria.postgresql.org; Sat, 27 Apr 2019 11:09:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hKLD0-0007Qu-GV for pgsql-general@arkaria.postgresql.org; Sat, 27 Apr 2019 11:09:30 +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 1hKLCz-0007ND-PI for pgsql-general@lists.postgresql.org; Sat, 27 Apr 2019 11:09:30 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hKLCv-0001SD-V4 for pgsql-general@lists.postgresql.org; Sat, 27 Apr 2019 11:09:28 +0000 Received: by mail-lf1-x141.google.com with SMTP id h126so4396580lfh.4 for ; Sat, 27 Apr 2019 04:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=puris-lv.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=hc5rtb2W3e+6FHckl0WuUFzu61qWO5AvrXZaUJGeXU4=; b=c1rEIfc02Vb41zQlR7FOWEVcGAsPv05e5d3iMIzOdMScFfdzFBfKX+mSXGFz7jlL8n c7SNstsk/Mi493jGtYeMo2pfqvsINkD7F5qlVvluWAq8Snbyet6eV9yTVUrORubnOyvC z65ewC/A2qTn/PLRt1eKwbdtHEc3JZV6nncAV0lSgC+V/C8w6sCuAJj4C9wgc6/taD+Y 3Qy7zgoC+RAl0xKFVU/ORPi0l5wjG9XRk46CFXVHi0sVdfp8vWq8WYJdEQ4iOAJijxVh iC2Hm03Zp5nPvmCltgJLSiS6NVSS3F8IDsWMdvIcVSob19w+WV7W5JeLt7G0/yWMJLBv g1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=hc5rtb2W3e+6FHckl0WuUFzu61qWO5AvrXZaUJGeXU4=; b=VmvUjC5VYXdHJXXSnwnW2KhujxSCv3i2kGxrRrrR8tkKgkfbgeclvMExCy8XBsuMzZ DSkTTPzeTKXoxAjM7NhSta9RSFf+wqn5NeuhLoOXZUfJ+mlGYjTZxsu1Iw1diREPAHG6 PMl8eNV5WgZyVN0/7yNIwi4q6ArQ17WYMrQnj/jb+xmn/3Nq9MbcNNBOpfZpsVM2i1zN Uz6nuKqmfNkl7Wa4YZCgD7mziGb52+7nog3k/ZaTThaMVXbGmVPjpfYx06O5+mEOGmIy OzPHiMH0yn/mxqfmcsGtaw8y55mf3HwioxtSDhuIgLgUDNnYFsxj3CQxBYJvnDnf1EUm iLyw== X-Gm-Message-State: APjAAAUzsknyyaI4g+OLWDjBjw10EzRkKw4ovAWFl7RphO6anQab3sd6 FwbxF2TbX3sP5aXflzQallDKWS6VjLWpPQ== X-Google-Smtp-Source: APXvYqyXNFQXJfywa+1iAo5hpjOU+omPEy2nG+Sna4ZJHU4DpUvYU8+BGFMFvaNw5Bpp2MQ9Mdb0bw== X-Received: by 2002:a19:f81a:: with SMTP id a26mr27448331lff.63.1556363363262; Sat, 27 Apr 2019 04:09:23 -0700 (PDT) Received: from [10.0.0.58] (172.126.164.82.customer.cdi.no. [82.164.126.172]) by smtp.gmail.com with ESMTPSA id l15sm5871780ljh.62.2019.04.27.04.09.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Apr 2019 04:09:22 -0700 (PDT) Date: Sat, 27 Apr 2019 13:09:14 +0200 From: =?utf-8?Q?J=C4=81nis_P=C5=ABris?= To: "Peter J. Holzer" Cc: pgsql-general@lists.postgresql.org Message-ID: <4d40030e-fa3f-41ab-88c6-c9030f98db98@Spark> In-Reply-To: <20190427105513.nqwaetx23t4j4kj6@hjp.at> References: <95b05f8d-990a-4f15-906f-24a011fc00ed@Spark> <695f797f-b02b-492a-94d3-0d5b4ab7c0a2@Spark> <31611.1556288224@sss.pgh.pa.us> <9718d4fc-de72-45bc-af1b-f759b9f2b29d@Spark> <20190427105513.nqwaetx23t4j4kj6@hjp.at> Subject: Re: TCP Resets when closing connection opened via SSL X-Readdle-Message-ID: 4d40030e-fa3f-41ab-88c6-c9030f98db98@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="5cc4385f_7fffca11_331" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --5cc4385f_7fffca11_331 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thank you, Peter. It makes more sense now, and I'm so glad someone else is able to reproduc= e this. To clarify on why I consider this a problem - It is not just the alerts o= n monitoring system. The alerts themselves can be tuned / thresholds incr= eased etc. The real issue (could argue this is non-issue), is the noise..= If something start to not work as expected besides this =22inconvenience=22= and start to produce TCP resets as well, this could potentially diminish= the troubleshooting tool visibility. That said. Now that someone else is able to reproduce this and I more cla= rity as to what may be going on (can explain to team), I can consider thi= s as =22known behaviour=22. Hopefully this will be addressed someday, but until then, we'll just have= to live with it. :) Med vennlig hilsen. Best regards, Janis Puris. On 27 Apr 2019, 12:55 +0200, Peter J. Holzer , wrote:= > On 2019-04-26 18:36:12 +0200, J=C4=81nis P=C5=ABris wrote: > > Thanks for the insight, Tom. > > > > > > It's fairly obvious from the postmaster log that the client side > > is not bothering to close the transaction it started > > > > > > Thats what I was also thinking, but I've managed to reproduce it with= > > autocommit or commit before closing connection as well. > > This is only reproducible with SSL connection. > > > > I've reproduced it with ubuntu package bundles certs, my own created,= generated > > with CA etc hence I do not think it is a problem with certificates th= emselves. > > This happens with various clients, php driver, java driver and also l= ibpq used > > by psycopg2. We are running a lot of different kind of microservices = and thus > > far I can tell, almost (if not all) of them have this problem manifes= t. > > > > I can not however reproduce this when doing something like > > =24 psql =22user=3Dpostgres sslmode=3Drequire host=3Dlocalhost dbname= =3Dpostgres=22 > > postgres=3D=23 =5Cq > > I can reproduce it in this case also (kernel 4.9, openssl 1.1.0j, > posgres 9.5.16). > > stracing psql shows this: > > send(3, =22=5C27=5C3=5C3=5C0=5C35fV=5C354=5C31v=5C332=5C10=5C22=5C202-=23= 8=5C5=5C267=5C5=5C202=5C346=5C3748=5C353=5C326&=5C374=5Crf=5C2776=22..., = 34, MSG=5FNOSIGNAL) =3D 34 > send(3, =22=5C25=5C3=5C3=5C0=5C32fV=5C354=5C31v=5C332=5C10=5C23=5C307=5C= 207=5C335V=5C355Lhh=5C=22=5C214=5C331=5C25l=5C352=5C27=5C32=5C332=5C357=22= , 31, MSG=5FNOSIGNAL) =3D 31 > close(3) =3D 0 > > I.e., psql sends some data (presumably a TLS close=5Fnotify alert) and > then closes the file descriptor. > > tcpdump shows this: > > 12:30:02.276188 IP6 localhost.47712 > localhost.postgresql: =46lags =5B= P.=5D, seq 414:445, ack 1239, win 360, options =5Bnop,nop,TS val 33741618= 6 ecr 337416186=5D, length 31 > 12:30:02.276243 IP6 localhost.47712 > localhost.postgresql: =46lags =5B= =46.=5D, seq 445, ack 1239, win 360, options =5Bnop,nop,TS val 337416186 = ecr 337416186=5D, length 0 > 12:30:02.276306 IP6 localhost.postgresql > localhost.47712: =46lags =5B= P.=5D, seq 1239:1270, ack 446, win 350, options =5Bnop,nop,TS val 3374161= 86 ecr 337416186=5D, length 31 > 12:30:02.276315 IP6 localhost.47712 > localhost.postgresql: =46lags =5B= R=5D, seq 2477517213, win 0, length 0 > > The first packet shown are the 31 bytes of the second send, then the > cliens sends a =46IN packet. Then the server replies with a packet of t= he > same length (so presumably also a close=5Fnotify alert). Since the clie= nt > has already closed the connection, it replies with a RST. > > One might argue that openssl should wait for the other side to reply > before closing the connection. But waiting doesn't really accomplish > anything from the application's point of view and introduces and > unnecessary delay. > > > This is an issue because we have a lot of connections being initiated= and > > closed. And this creates a lot of TCP resets. > > Why are those resets a problem=3F (If the answer is =22our monitoring > software complains about them=22 then the question becomes =22why does = your > monitoring software think they are a problem=3F=22) > > hp > > -- > =5F =7C Peter J. Holzer =7C we build much bigger, better disasters now > =7C=5F=7C=5F) =7C =7C because we have much more sophisticated > =7C =7C =7C hjp=40hjp.at =7C management tools. > =5F=5F/ =7C http://www.hjp.at/ =7C -- Ross Anderson --5cc4385f_7fffca11_331 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Thank you, Peter= .

It makes more sense now, and I'm so glad someone else is able to rep= roduce this.

To clarify on why I consider this a problem - It is not just the ale= rts on monitoring system. The alerts themselves can be tuned / thresholds= increased etc. The real issue (could argue this is non-issue), is the no= ise..

If something start to not work as expected besides this =22inconveni= ence=22 and start to produce TCP resets as well, this could potentially d= iminish the troubleshooting tool visibility.

That said. Now that someone else is able to reproduce this and I mor= e clarity as to what may be going on (can explain to team), I can conside= r this as =22known behaviour=22.

Hopefully this will be addressed someday, but until then, we'll just= have to live with it. :)

Med vennlig hilsen.
Best regards, Janis Puris.
On 27 Apr 2019,= 12:55 +0200, Peter J. Holzer <hjp-pgsql=40hjp.at>, wrote:
On 2019-04-26 18:36:12 +0200, = J=C4=81nis P=C5=ABris wrote:
Thanks for the insight, Tom.

It's fairly obvious from the postmaster log that the client side
is not bothering to close the transaction it started


Thats what I was also thinking, but I've managed to reproduce it with
autocommit or commit before closing connection as well.
This is only reproducible with SSL connection.

I've reproduced it with ubuntu package bundles certs, my own created, gen= erated
with CA etc hence I do not think it is a problem with certificates themse= lves.
This happens with various clients, php driver, java driver and also libpq= used
by psycopg2. We are running a lot of different kind of microservices and = thus
far I can tell, almost (if not all) of them have this problem manifest.
I can not however reproduce this when doing something like
=24 psql =22user=3Dpostgres sslmode=3Drequire host=3Dlocalhost dbname=3Dp= ostgres=22
postgres=3D=23 =5Cq

I can reproduce it in this case also (kernel 4.9, openssl 1.1.0j,
posgres 9.5.16).

stracing psql shows this:

send(3, =22=5C27=5C3=5C3=5C0=5C35fV=5C354=5C31v=5C332=5C10=5C22=5C202-=23= 8=5C5=5C267=5C5=5C202=5C346=5C3748=5C353=5C326&=5C374=5Crf=5C2776=22.= .., 34, MSG=5FNOSIGNAL) =3D 34
send(3, =22=5C25=5C3=5C3=5C0=5C32fV=5C354=5C31v=5C332=5C10=5C23=5C307=5C2= 07=5C335V=5C355Lhh=5C=22=5C214=5C331=5C25l=5C352=5C27=5C32=5C332=5C357=22= , 31, MSG=5FNOSIGNAL) =3D 31
close(3) =3D 0

I.e., psql sends some data (presumably a TLS close=5Fnotify alert) and then closes the file descriptor.

tcpdump shows this:

12:30:02.276188 IP6 localhost.47712 > localhost.postgresql: =46lags =5B= P.=5D, seq 414:445, ack 1239, win 360, options =5Bnop,nop,TS val 33741618= 6 ecr 337416186=5D, length 31
12:30:02.276243 IP6 localhost.47712 > localhost.postgresql: =46lags =5B= =46.=5D, seq 445, ack 1239, win 360, options =5Bnop,nop,TS val 337416186 = ecr 337416186=5D, length 0
12:30:02.276306 IP6 localhost.postgresql > localhost.47712: =46lags =5B= P.=5D, seq 1239:1270, ack 446, win 350, options =5Bnop,nop,TS val 3374161= 86 ecr 337416186=5D, length 31
12:30:02.276315 IP6 localhost.47712 > localhost.postgresql: =46lags =5B= R=5D, seq 2477517213, win 0, length 0

The first packet shown are the 31 bytes of the second send, then the
cliens sends a =46IN packet. Then the server replies with a packet of the=
same length (so presumably also a close=5Fnotify alert). Since the client=
has already closed the connection, it replies with a RST.

One might argue that openssl should wait for the other side to reply
before closing the connection. But waiting doesn't really accomplish
anything from the application's point of view and introduces and
unnecessary delay.

This is an issue because we ha= ve a lot of connections being initiated and
closed. And this creates a lot of TCP resets.

Why are those resets a problem=3F (If the answer is =22our monitoring
software complains about them=22 then the question becomes =22why does yo= ur
monitoring software think they are a problem=3F=22)

hp

--
=5F =7C Peter J. Holzer =7C we build much bigger, better disasters now =7C=5F=7C=5F) =7C =7C because we have much more sophisticated
=7C =7C =7C hjp=40hjp.at =7C management tools.
=5F=5F/ =7C http://www.hjp.at/ =7C -- Ross Anderson <https://www.edge.= org/>
--5cc4385f_7fffca11_331--