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 1nmyx5-0007Id-4f for pgsql-hackers@arkaria.postgresql.org; Fri, 06 May 2022 14:29:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nmyx4-0004VQ-2q for pgsql-hackers@arkaria.postgresql.org; Fri, 06 May 2022 14:29:02 +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 1nmyx3-0004V7-Q4 for pgsql-hackers@lists.postgresql.org; Fri, 06 May 2022 14:29:01 +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 1nmyx1-0003PI-QK for pgsql-hackers@postgresql.org; Fri, 06 May 2022 14:29:01 +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 246ESr0u2889551; Fri, 6 May 2022 10:28:53 -0400 From: Tom Lane To: Peter Eisentraut cc: Alvaro Herrera , Fabien COELHO , pgsql-hackers Subject: Re: libpq async duplicate error results In-reply-to: References: <202202081500.xl3iwa7doscz@alvherre.pgsql> <394797.1645388816@sss.pgh.pa.us> <1262938.1645658107@sss.pgh.pa.us> <1421785.1645723238@sss.pgh.pa.us> Comments: In-reply-to Peter Eisentraut message dated "Fri, 06 May 2022 15:49:28 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2889549.1651847333.1@sss.pgh.pa.us> Date: Fri, 06 May 2022 10:28:53 -0400 Message-ID: <2889550.1651847333@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > I took another look at this. The output from the test program at the > beginning of the thread is now (master branch): > ... > command = SELECT 'after'; > PQsendQuery() error: FATAL: terminating connection due to administrator > command > server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > no connection to the server > It appears the "after" query is getting the error message from the > previous cycle somehow. What is happening is that this bit in PQsendQueryStart is deciding not to clear the message buffer because conn->cmd_queue_head isn't NULL: /* * If this is the beginning of a query cycle, reset the error state. * However, in pipeline mode with something already queued, the error * buffer belongs to that command and we shouldn't clear it. */ if (newQuery && conn->cmd_queue_head == NULL) pqClearConnErrorState(conn); So apparently the fault is with the pipelined-query logic. I'm not sure what cleanup step is missing though. regards, tom lane