Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rADzB-005VlE-P1 for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Dec 2023 18:48:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rADzA-000oTC-A3 for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Dec 2023 18:48:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rADz8-000oT4-QZ for pgsql-bugs@lists.postgresql.org; Mon, 04 Dec 2023 18:48:04 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rADz4-00A5uv-Pk for pgsql-bugs@lists.postgresql.org; Mon, 04 Dec 2023 18:48:02 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id AA7BA5C013C; Mon, 4 Dec 2023 13:47:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 04 Dec 2023 13:47:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1701715675; x= 1701802075; bh=D47yuWyJl1DQxQ/Eg9TIVpnV9w8Obp3okkN17fTGUzM=; b=T O/C+pSHm6zM1kgmDV/RGhWD1k2AvtfkxGdkoMxVgq+vpMFRuavX1q6LRf1XdjZhw HvLonY8vIurtr5imgzyrJ9nkvL1SfGYIfpxgF4AT6VsdLuypBOpQ/F7PdPY+0xMZ tJEC/IiN0U9JJiEICNZLBvJxatA4RwN+lF//0YhOvOP1lQ6vrbc9SMFfm3re9haI frv7ynm3mF9w6956hBxfnNnh404O/YkaAU9QRkjDXOBNSBWKyi3I5o4sf0vmHpnk Lu8RQa4SurQJsSENtNkHjcgMhiVncyepGRnYXB/taq0F1BlVa4lO3gonQRpYE10g t0hKUMjJcRRjCprWCmcIQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudejiedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkgggtugfgjgesmh ekreertddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghr rhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepudelkeekgf dttdettdekgfduvdeiffelteegjeeihfetheekveeftedtuddvhfeunecuffhomhgrihhn pegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdho rhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 4 Dec 2023 13:47:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1701715671; bh=rqZ0pbRbDWYuegExi55Wvrkq3G29rB69OJ20KQI+iIA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=fEG/y8OKteGCMngB11Wchb0Pis1Gv9vT8OfthLRn8sAfMF3kdxr3XV1ZpmBTycpPh Hb4P20aT6xLNBe/5dK1auENMaYC3EWfwOFxrevHGkzbkFgw4qNv00CF8qmg9GVWS3D GEmLTOqTZSFZEhqGTzv1fuu8wgVCpFoICfcgkkbf4V7VX0ru/u2doZ2hKB49UHR47r xcMV9AVzmn3gLNLyJMRjbHZURFaj+TxAo+czqsjJkph/KGqiB5FyBDUJ+Ee28bsTCV aflSkfQ5QgOZOOOKhT4raAFs8DGt0scrP9eJd0RkifuTOmOtUxqaKpK2OedigOEreo DWhFRkhUEXfoA== Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 520ACBD; Mon, 4 Dec 2023 19:47:51 +0100 (CET) Date: Mon, 4 Dec 2023 19:47:51 +0100 From: Alvaro Herrera To: Ivan Trofimov Cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #17948: libpq seems to misbehave in a pipelining corner case Message-ID: <202312041847.iur3zphjejur@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="qxllmt3wv7p6izbt" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7f6e2986-158d-4650-e8df-56e9bfc48da1@yandex.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --qxllmt3wv7p6izbt Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2023-Dec-02, Ivan Trofimov wrote: > Thank you for looking into this, much appreciated. > > Yes, I can confirm that the patch fixes both the busy-loop and > client<->server desynchronization problem for me. Great, thanks for the confirmation. Mulling it over while writing better comments for it, I realized that it could still be somewhat brittle, and it's also confusing that part of the logic is in PQgetResult and the rest in pqCommandQueueAdvance; so I moved it all to the latter, which also lets me document it more clearly in the comments. I addressed the brittleness by changing what to test: instead of just "it's an error, then do nothing if the queue has a SYNC", we can verify that we actually have a matching SYNC in both places. This seems much better. Patch v2 attached. I'll be pushing this to 14+ tomorrow, unless something ugly comes up. Thanks for reporting this problem! -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens) --qxllmt3wv7p6izbt Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v2-0001-Fix-handling-of-errors-in-libpq-pipelines.patch" Content-Transfer-Encoding: 8bit