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 1wSoOF-0007Hh-2R for pgsql-bugs@arkaria.postgresql.org; Fri, 29 May 2026 04:00:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSoOE-001NyI-0l for pgsql-bugs@arkaria.postgresql.org; Fri, 29 May 2026 04:00:06 +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 1wSoOD-001Ny9-2n for pgsql-bugs@lists.postgresql.org; Fri, 29 May 2026 04:00:06 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wSoOB-000000003xl-38dY for pgsql-bugs@lists.postgresql.org; Fri, 29 May 2026 04:00:05 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49041e84237so59348385e9.1 for ; Thu, 28 May 2026 21:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780027203; x=1780632003; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=deXX4THnV7D1Fw+zws+67T7MRW1RTRpXiTvtdrFaG3k=; b=TcMOxB9ofvfsaFgj88ZvW4kxZDnU1EW9CSBxWBXIGxY/hj7THvmsuKlsN62UcOQGzy sYm258bpot4w65AMx7ZdlhjgsrthQPK59dmNDhAbQsTQveREF+sEJ+3AtHxvZ5/tVzCX WNp29LK9YOHjy4KKZUCvLk8CWow7zySh5CxogH3Ig9izQrtrj2KzXLHewMBXmTXid5Ba KZjXP32WT7rTXXFJJDeUMtxrVZFJHlv0ADDCkPtNvLaup4KiE6/1/pKTahHQgs/GFKPx YfrjbfUo5d+qpfaEG4ds4m2kfxJvlFi469zFtlzoMA3/ay3gnkeI33qDwU5mfcLjRvFx k7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780027203; x=1780632003; h=in-reply-to:from:content-language:references: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=deXX4THnV7D1Fw+zws+67T7MRW1RTRpXiTvtdrFaG3k=; b=mXF6pk+ktyQZEJEZYKdRf/Stv69KMRgP6Lgj2Yt9ARR6qXSOE2+Szj/HNuAtRGkrQd spo7oCsip6lzHlxZ4ylr5S3KBT5pvqje10p33VLllzaNhORMYip8kbbIzt3/qpM91qHb HGZnbq9GnChrQHoMYrKIgXmLfBTaogMbqVxL4XwFg1pvo95gL43IMEsyFaUmFNL0MtzU PEuI4xq1mnxOW9K/Wg718ICYEqu3CzllMkKw1JHIC3jkNkGZi36pF1iSiPcp13w1gX0u pE0BxVWyUgV8eaIanyhDcH+VgedNt5dNkj3OYguqF6yPUoaCge2AKCfnIdbqIXhc8SOj Jnuw== X-Forwarded-Encrypted: i=1; AFNElJ9z7KTzNHH8IcupiIhCLoDZnefuVHzuNpmO95CHRiNtq5hzEun5aY1i5eLUa5y29GyKqwEi9ftrOr3B@lists.postgresql.org X-Gm-Message-State: AOJu0YyHAlfKKEvhdyd21Ca/qYn8Emh8xtRY7RVbQN3Gb+3vLisckyMA kK//Hh6g3aTjtGXFXed4m0OR9bP6446ibD2Nfrgqm+gTeX4FWfq0J4ur X-Gm-Gg: Acq92OE7IQWfTmz1Yu/0R5ZpVV6kcw+XIHGVYVa0WhOgr8xfb2TK5Mez5pI4fY5hF7z q4TlkmD2imCDtuRWaC5kT5yhEd/a1E+etGFBqLY2OvgkiDd95FCz/TatDdzC41FO2m6ufBkjfOO UuwmDTy2Mjh/ME1MsUlUeYlMhOhZ8lOJaBRnbt8Zsg9hYPZZ6/Q0sfiXXJCr0JOXZFSu9dGR8IH qfEEeygGfv8EpWVUxsJ6AsiUz2py0mf7p1QXBXbo1FFo9xDkvndHg30SbFQKYskccZ/6LPwWy76 Uq6GX0vERj39mpaTjoGt+EPBizpUR/TcSF2+5bkL/7fMtiNLcDY4Tb7GSu7uhGuB7cH9/b5bmK/ 3rkx/hVkStx7NkWOMQJCYAY6ezdMoIIAwkbxyMKoAMun4boCi3+VigzbPXKii83F5ASFy2dMY8F c909nsCuis9Nn2otxnfnCEbMhUNT21Dbt3WFQ= X-Received: by 2002:a05:600c:6b08:b0:490:3838:1548 with SMTP id 5b1f17b1804b1-4909c15b09dmr10871885e9.13.1780027202554; Thu, 28 May 2026 21:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.143]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef354c682sm441818f8f.23.2026.05.28.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 May 2026 21:00:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------P1Tt1vfzYPTg9sti9cfX9GHZ" Message-ID: Date: Fri, 29 May 2026 07: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 , 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. --------------P1Tt1vfzYPTg9sti9cfX9GHZ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Michael, 28.05.2026 08:26, Michael Paquier wrote: > On Thu, May 28, 2026 at 12:51:38PM +0900, Michael Paquier wrote: >> I am completely sure yet, but it looks like we will need to be smarter >> with the handling of the number of piped commands by tracking them >> across the syncs in the shape of a queue, or something like that? So >> it feels like we need to think harder about the tracking of this >> activity depending on the state of the pipeline we're in. Or we could >> lift some of these assertions, but that would not be right to me. > Hmm. Taking a step back this would be overcomplicating things. As > long as we are careful to consume the synced results still in a > pipeline, it looks like we should be fine. While digging into it, I > have found a third assertion that was triggerable with > available_results at the end of the pipeline, once I began mixing > \getresults with a deferred error. > > This stuff is tricky enough that I may not have overseen all the > patterns possible, of course, at least this is progress. > > Alexander, what do you think? While testing the patch, I've observed apparently new anomaly. psql got stuck inside this loop:     if (end_pipeline)     {         /*          * Reset available/requested results.  Normally these are already 0,          * but an error generated by Sync processing itself can leave some of          * them behind.  Consume them before exiting pipeline mode.          */         while (pset.piped_syncs > 0)         {             PGresult   *remaining = PQgetResult(pset.db);             if (remaining == NULL)                 continue; ...         } it's happening upon/after postgres process termination, so PQgetResult() returns NULL, pset.piped_syncs == 1. I need more time to look deeper and to come with a reproducer, but maybe you can already see what's wrong. Best regards, Alexander --------------P1Tt1vfzYPTg9sti9cfX9GHZ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello Michael,

28.05.2026 08:26, Michael Paquier wrote:
On Thu, May 28, 2026 at 12:51:38PM +0900, Michael Paquier wrote:
I am completely sure yet, but it looks like we will need to be smarter
with the handling of the number of piped commands by tracking them
across the syncs in the shape of a queue, or something like that?  So
it feels like we need to think harder about the tracking of this
activity depending on the state of the pipeline we're in.  Or we could
lift some of these assertions, but that would not be right to me.
Hmm.  Taking a step back this would be overcomplicating things.  As
long as we are careful to consume the synced results still in a
pipeline, it looks like we should be fine.  While digging into it, I
have found a third assertion that was triggerable with
available_results at the end of the pipeline, once I began mixing
\getresults with a deferred error.

This stuff is tricky enough that I may not have overseen all the
patterns possible, of course, at least this is progress.

Alexander, what do you think?

While testing the patch, I've observed apparently new anomaly. psql got
stuck inside this loop:
    if (end_pipeline)
    {
        /*
         * Reset available/requested results.  Normally these are already 0,
         * but an error generated by Sync processing itself can leave some of
         * them behind.  Consume them before exiting pipeline mode.
         */
        while (pset.piped_syncs > 0)
        {
            PGresult   *remaining = PQgetResult(pset.db);

            if (remaining == NULL)
                continue;
...
        }

it's happening upon/after postgres process termination, so PQgetResult()
returns NULL, pset.piped_syncs == 1. I need more time to look deeper and
to come with a reproducer, but maybe you can already see what's wrong.

Best regards,
Alexander
--------------P1Tt1vfzYPTg9sti9cfX9GHZ--