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 1jW418-0001vs-3z for pgsql-general@arkaria.postgresql.org; Tue, 05 May 2020 20:18:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jW416-0007On-RB for pgsql-general@arkaria.postgresql.org; Tue, 05 May 2020 20:18:12 +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 1jW415-0007Og-Cw for pgsql-general@lists.postgresql.org; Tue, 05 May 2020 20:18:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jW40y-0001qp-4x for pgsql-general@lists.postgresql.org; Tue, 05 May 2020 20:18:09 +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 045KI2Iw022722; Tue, 5 May 2020 16:18:02 -0400 From: Tom Lane To: Matthias Apitz cc: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPARE sid_sisisinst FROM :select_anw;' In-reply-to: <20200505181200.GA3640@c720-r342378> References: <20200427122123.GA11416@sh4-5.1blu.de> <5198.1587991204@sss.pgh.pa.us> <20200427130618.GA24964@sh4-5.1blu.de> <16680.1587994839@sss.pgh.pa.us> <20200505181200.GA3640@c720-r342378> Comments: In-reply-to Matthias Apitz message dated "Tue, 05 May 2020 20:12:00 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <22720.1588709882.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 05 May 2020 16:18:02 -0400 Message-ID: <22721.1588709882@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Matthias Apitz writes: > El d=C3=ADa lunes, abril 27, 2020 a las 09:40:39a. m. -0400, Tom Lane es= cribi=C3=B3: >> If you're in a position to run a modified server, you could try >> inserting a debug log message: > I've added the printout of the length in this case and another one, and > see this in the server's log file: > 2020-05-04 10:05:49.977 CEST [32092] LOG: invalid length 33554940 of st= artup packet > 2020-05-04 10:05:50.207 CEST [32094] LOG: invalid length 33554940 of st= artup packet > 2020-05-04 12:32:50.781 CEST [20334] LOG: bogus received message length= : 1650422894 > 2020-05-04 12:36:41.293 CEST [20380] LOG: bogus received message length= : 1650422894 > 2020-05-04 12:39:39.461 CEST [20441] LOG: bogus received message length= : 1650422894 > 2020-05-04 13:01:50.566 CEST [24222] LOG: bogus received message length= : 1650422894 Hmph. That confirms that we're getting a bogus message length, but not much more. It's quite interesting though that the bogus value is always the same. According to my calculator 1650422894 corresponds to ASCII "b_tn", or possibly "nt_b" depending on what you want to assume about endianness, which looks tantalizingly like it could be a fragment of a SQL query. So I'm still leaning to the idea that the client has sent a malformed query stream --- but how? Or if the data got corrupted in transit, how did that happen? Can you work backwards to what the client was doing just before the point at which it hangs? It's likely that the particular PQprepare call it's stuck on is just the victim of prior misfeasance. If you can find "b_tn" or "nt_b" in any strings the client should have been sending up to this point, that might shed light too. regards, tom lane