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 1lahGJ-0006at-Qb for pgsql-general@arkaria.postgresql.org; Sun, 25 Apr 2021 16:05:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lahGH-0003he-TU for pgsql-general@arkaria.postgresql.org; Sun, 25 Apr 2021 16:05:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lahGH-0003hX-M7 for pgsql-general@lists.postgresql.org; Sun, 25 Apr 2021 16:05:33 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lahGE-0007sD-ON for pgsql-general@lists.postgresql.org; Sun, 25 Apr 2021 16:05:32 +0000 Received: from [188.174.61.177] (helo=c720-r368166.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lahGC-0003E6-Hp; Sun, 25 Apr 2021 18:05:28 +0200 Received: from c720-r368166.fritz.box (localhost [127.0.0.1]) by c720-r368166.unixarea.de (8.16.1/8.14.9) with ESMTPS id 13PG5R44002510 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 25 Apr 2021 18:05:27 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by c720-r368166.fritz.box (8.16.1/8.14.9/Submit) id 13PG5Rr1002509; Sun, 25 Apr 2021 18:05:27 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: c720-r368166.fritz.box: guru set sender to guru@unixarea.de using -f Date: Sun, 25 Apr 2021 18:05:27 +0200 From: Matthias Apitz To: Tom Lane Cc: Laurenz Albe , pgsql-general@lists.postgresql.org Subject: Re: client waits for end of update operation and server proc is idle Message-ID: Reply-To: Matthias Apitz References: <0551daad25ee518071e002ca17c4b6dac08a236c.camel@cybertec.at> <1935464.1619365905@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1935464.1619365905@sss.pgh.pa.us> X-Operating-System: FreeBSD 13.0-CURRENT r368166 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.61.177 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk El día domingo, abril 25, 2021 a las 11:51:45a. m. -0400, Tom Lane escribió: > Matthias Apitz writes: > > At the end of the day, it turned out that out client caused the problem. > > Because we were hunting some other issue, the client was logging some > > message with fprintf(stderr, ...) but the fd=2 was not stderr, fd=2 was the > > connection to the socket of the PostgreSQL server. And ofc the Pos > > server could not understand our human message. > > Hmph. So why wasn't this visible in the tcpdump trace? It was visible. That's why I detected it while looking up the TCP packages before the UPDATE: 10:57:16.051326 IP 127.0.0.1.52288 > 127.0.0.1.5432: Flags [P.], seq 14280:14407, ack 120304, win 512, options [nop,nop,TS val 3424445708 ecr 3424445708], length 127 0x0000: 4500 00b3 b84e 4000 4006 83f4 7f00 0001 E....N@.@....... 0x0010: 7f00 0001 cc40 1538 d9b9 44bb fcd1 afb7 .....@.8..D..... 0x0020: 8018 0200 fea7 0000 0101 080a cc1c e50c ................ 0x0030: cc1c e50c 5352 502d 3236 3937 363a 2072 ....SRP-26976:.r 0x0040: 6573 746f 7265 6420 7374 7275 6374 206b estored.struct.k 0x0050: 6574 7465 7361 747a 2066 6f72 2073 6574 ettesatz.for.set 0x0060: 6964 3a32 2c20 6465 736b 3a33 3831 3832 id:2,.desk:38182 0x0070: 3038 302c 2066 656c 646e 723a 362c 206b 080,.feldnr:6,.k 0x0080: 6174 6b65 793a 3136 3839 3532 3937 392c atkey:168952979, 0x0090: 206b 6574 7465 7361 747a 2e66 7265 693a .kettesatz.frei: 0x00a0: 302c 206b 6574 7465 7361 747a 2e61 6e7a 0,.kettesatz.anz 0x00b0: 3235 0a 25. 10:57:16.051388 IP 127.0.0.1.52288 > 127.0.0.1.5432: Flags [P.], seq 14407:14812, ack 120304, win 512, options [nop,nop,TS val 3424445708 ecr 3424445708], length 405 0x0000: 4500 01c9 b84f 4000 4006 82dd 7f00 0001 E....O@.@....... 0x0010: 7f00 0001 cc40 1538 d9b9 453a fcd1 afb7 .....@.8..E:.... 0x0020: 8018 0200 ffbd 0000 0101 080a cc1c e50c ................ 0x0030: cc1c e50c 5000 0000 7e00 7570 6461 7465 ....P...~.update 0x0040: 2070 6572 5f6b 6574 7465 2073 6574 2064 .per_kette.set.d 0x0050: 6573 6b6e 7220 3d20 2431 2020 2c20 6672 esknr.=.$1..,.fr > > My initial thought was that the server process should log a message > and drop the connection once it received something that didn't look > like a valid Postgres-protocol message, on the assumption that > message-boundary sync could never be recovered reliably. But on > further thought, it would start by taking the second through fifth > bytes of the input as a message length, and it wouldn't really do > anything interesting until it had collected that much input --- > and, if those bytes were text, that would look like a large number. > So what the server is really doing is waiting for the rest of the > imaginary message, which will never arrive. > > Maybe we should have more sanity checking on alleged message lengths. > I recall there is some checking of that sort in libpq, but I'm less > sure about the server. Yes, this would make sense. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub