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 1lah38-0005xV-Bs for pgsql-general@arkaria.postgresql.org; Sun, 25 Apr 2021 15:51:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lah35-0006y9-V1 for pgsql-general@arkaria.postgresql.org; Sun, 25 Apr 2021 15:51:55 +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 1lah35-0006y2-Ne for pgsql-general@lists.postgresql.org; Sun, 25 Apr 2021 15:51:55 +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 1lah2z-0004MS-AX for pgsql-general@lists.postgresql.org; Sun, 25 Apr 2021 15:51:55 +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 13PFpjXg1935465; Sun, 25 Apr 2021 11:51:45 -0400 From: Tom Lane To: Matthias Apitz cc: Laurenz Albe , pgsql-general@lists.postgresql.org Subject: Re: client waits for end of update operation and server proc is idle In-reply-to: References: <0551daad25ee518071e002ca17c4b6dac08a236c.camel@cybertec.at> Comments: In-reply-to Matthias Apitz message dated "Sun, 25 Apr 2021 17:37:52 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1935463.1619365905.1@sss.pgh.pa.us> Date: Sun, 25 Apr 2021 11:51:45 -0400 Message-ID: <1935464.1619365905@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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? 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. regards, tom lane