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.96) (envelope-from ) id 1wTukz-000pUA-0g for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Jun 2026 05:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wTukx-008trS-2C for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Jun 2026 05:00:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wTukx-008trK-11 for pgsql-bugs@lists.postgresql.org; Mon, 01 Jun 2026 05:00:07 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wTukv-00000000WVS-1Cnl for pgsql-bugs@lists.postgresql.org; Mon, 01 Jun 2026 05:00:06 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so73086405e9.0 for ; Sun, 31 May 2026 22:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780290003; x=1780894803; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ejcqPIsUinwnai5vGwAm5t3tfo1jbEChYZGaKiP3mT4=; b=SmcZ8eU8H+1ewM8sxikXCDp91bj7PT0kyWBCovVb21CuCVxgmAzZbRMDfdyrIOagux 9JaP4MZecoHvswFfHrF/KRatTVppiois5DnKvlI93UDopuWa9Z6DT6NYFq8yjBvRmFiZ f8ihrBTHX6Bw0P+LHuP/yJjrrU9t/mwy3wJz36iUmrpEi+HaF+G6zhkRdxKxnKAv0O8d 9pXEnCo+jjcKgO0jPI8xJ6UpYokhV/fI7s20jLI+MtsxJk1SdO0UQtTS9XbP1JWhYf28 WR+ExmYrkZhMVQk7AxTtHhaOVNoY51H0J3XzqS2biC7uLRbe+uN2zRb4RbfwaOMbR/YU FE2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780290003; x=1780894803; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ejcqPIsUinwnai5vGwAm5t3tfo1jbEChYZGaKiP3mT4=; b=EIKsv40Qti1HEqaCS9FqfOHOwG3CbQh7FIWQQTWoPB36sjODG1hw/0QkCjmLK9kG92 8B/PUuQ2mu4EwaxrW39NJSaNz4lIW9JJXScY+o9cz3gy3fcG2Fb07ho02UGXE2Llv6NW uWYkwmZ/5YqKEbhzE5KYTa5z2pPyxSlO6MvYAagbu6Xp5cSxG1BbB0YoPN+iUOUA2NYz 7n50pzS3o2RDMZ7Ft26GlODGYK8ooFb/oUijLUb0nCyxzjSanCNE1R/mjwRdWXzSglAU sGB051JyY6GHfOemVXBmbPiOtct3iLS4+uWaC4xnnSUG/rIBZpxp5YKaC2H9GyNrpKBe pHPg== X-Gm-Message-State: AOJu0YyOdU1RGu9Lo6hIRprS31C7KwFXfBA/NVyaczlXwmauXjIhsOX+ gKrxD24DEAnOG8HyE5o8bkPgTDQVLPD3EFNGTDTS+9mJ4tjdqPDiA0BESsmWrtlf X-Gm-Gg: Acq92OH49RNCUlZFQTpfo27fvSNHFOdiIXnQwsGAxK1240g5emYluDK0wOwLgh2ZF6L T5ALSDK8iWJrOTIGsm4/UbG2gY6mLbHeWZUTYlxT/lgK2S2zOL/3zLCqRzsehIOMKb+tl2J3vvI /7mwYhCzD8YpRwl4DoAVHxVtYsdvIp9VMkxyYMOPl0pkohvFzy5W8VnjupcOwzlmLEENrstBTcK hc+b9hT3qnvyEGVHKN+y1qbLN9mx7x0Tv+oZbS8H3JRGUAQnWr+SRQkB/N+Tu2kNYz6yBICqGOm QlqK01pFRYkyjXXg/A+5VhyLc9UTTF5Y0SkGBvPI717T5J6KLgTGnH2vRyv3VvPsmx1ASl/JKBz CIS6tYxop7vtMu6Qca5jlpI/ej4TGk8GFdU+t5vkWPeEW22ImZHHkWa917j7fxushmFop9GPnew sIwxn6Dyacw16GPKf4bK2jES8BAiljoygAm/U= X-Received: by 2002:a05:600c:4f89:b0:489:e696:8362 with SMTP id 5b1f17b1804b1-490a292ed68mr167604105e9.13.1780290003100; Sun, 31 May 2026 22:00:03 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.143]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909d696f25sm332147905e9.5.2026.05.31.22.00.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 May 2026 22:00:02 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------ptXOi7TeubMyfKchTvH0Xu3P" Message-ID: <3f3dc050-aab1-4908-a6b8-bdadafd451cc@gmail.com> Date: Mon, 1 Jun 2026 08:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19494: Error on transaction commit inside pipeline triggers psql's Assert To: Michael Paquier Cc: pgsql-bugs@lists.postgresql.org References: <19494-97a86d84fee71c47@postgresql.org> Content-Language: en-US From: Alexander Lakhin In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------ptXOi7TeubMyfKchTvH0Xu3P Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Michael, 01.06.2026 05:11, Michael Paquier пишет: > I have looked at that as well, and I don't think that this is fixable > only from the point of psql, because the error injected creates a > state where libpq's internal command queue gets out of sync regarding > what the backend has sent. The only thing that could be done is > inside libpq, as far as I can see, where we should try to detect that > the state is not synchronized anymore and fail rather than block. So > IMO, and with the error injected (which would never happen in > production in practice), the best thing I can come up with is the > attached for now. > > One thing that I could see ourselves do as an extra improvement in > ExecQueryAndProcessResults() where we consume the results and check if > we're still in a busy state (some PQconsumeInput+PQisBusy). I don't > think that this should be a problem in practice, but this feels like > just hiding the real problem on the libpq side with the inconsistent > protocol state generated by the backend. I have also quickly tested > an approach based on that, unfortunately this leads to some > instability in the tests to due the async nature of the commands. > > Anyway, the v3 attached passes the regression tests, handles the > pg_terminate_backend() case gracefully, handles the error case with > the error injected on backend-side a but better, and can avoid > some of the issues in the fourth case, but not all as we don't have > access to the pipe state when reaching the results do to the backend > missing up with the libpq state. Handling the 4th case more > gracefully would require some libpq changes, which may not justify the > cases we are dealing with here, at least to me. As a whole, I'd feel > that v3 is a good improvement in itself, and it addresses your > original issues and the assertions. > > What do you think? I agree with your points, the v3 looks good to me. Thank you for paying attention to all of these issues! Best regards, Alexander --------------ptXOi7TeubMyfKchTvH0Xu3P Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello Michael,

01.06.2026 05:11, Michael Paquier пишет:
I have looked at that as well, and I don't think that this is fixable 
only from the point of psql, because the error injected creates a
state where libpq's internal command queue gets out of sync regarding
what the backend has sent.  The only thing that could be done is
inside libpq, as far as I can see, where we should try to detect that
the state is not synchronized anymore and fail rather than block.  So
IMO, and with the error injected (which would never happen in
production in practice), the best thing I can come up with is the
attached for now.

One thing that I could see ourselves do as an extra improvement in
ExecQueryAndProcessResults() where we consume the results and check if
we're still in a busy state (some PQconsumeInput+PQisBusy).  I don't
think that this should be a problem in practice, but this feels like
just hiding the real problem on the libpq side with the inconsistent
protocol state generated by the backend.  I have also quickly tested
an approach based on that, unfortunately this leads to some
instability in the tests to due the async nature of the commands.

Anyway, the v3 attached passes the regression tests, handles the
pg_terminate_backend() case gracefully, handles the error case with
the error injected on backend-side a but better, and can avoid 
some of the issues in the fourth case, but not all as we don't have
access to the pipe state when reaching the results do to the backend
missing up with the libpq state.  Handling the 4th case more
gracefully would require some libpq changes, which may not justify the 
cases we are dealing with here, at least to me.  As a whole, I'd feel
that v3 is a good improvement in itself, and it addresses your
original issues and the assertions.

What do you think?

I agree with your points, the v3 looks good to me. Thank you for paying
attention to all of these issues!

Best regards,
Alexander
--------------ptXOi7TeubMyfKchTvH0Xu3P--