public inbox for [email protected]
help / color / mirror / Atom feedFrom: SATYANARAYANA NARLAPURAM <[email protected]>
To: Alexander Korotkov <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures
Date: Thu, 9 Apr 2026 14:37:44 -0700
Message-ID: <CAHg+QDd4NK2zjW6hPmS+Xr9UUdy+DAtywHeQhvcG+BXBEX0nEA@mail.gmail.com> (raw)
In-Reply-To: <CAPpHfdtJ_oZ3qJvXWAtOV4k02=m1P6AQUgoBofNgytQ3KyotbQ@mail.gmail.com>
References: <CAHg+QDcN-n3NUqgRtj=BQb9fFQmH8-DeEROCr=PDbw_BBRKOYA@mail.gmail.com>
<CAPpHfdsZ6YrzX-5uenwvw1VXuG7mpBXSOT6JFTg6aCCC0SaNEg@mail.gmail.com>
<CAHg+QDevycEwWfTMJ6ADZQJR9YSMcsAf=Dg=vH2R8Efcx1NH1w@mail.gmail.com>
<CAPpHfdtJ_oZ3qJvXWAtOV4k02=m1P6AQUgoBofNgytQ3KyotbQ@mail.gmail.com>
Hi Alexander,
On Thu, Apr 9, 2026 at 5:28 AM Alexander Korotkov <[email protected]>
wrote:
> On Thu, Apr 9, 2026 at 10:27 AM SATYANARAYANA NARLAPURAM
> <[email protected]> wrote:
> > On Wed, Apr 8, 2026 at 11:00 PM Alexander Korotkov <[email protected]>
> wrote:
> >> On Thu, Apr 9, 2026 at 5:03 AM SATYANARAYANA NARLAPURAM
> >> <[email protected]> wrote:
> >> > An assertion failure (server crash in assert-enabled builds) occurs
> when WAIT FOR LSN ... INTO is used inside PL/pgSQL DO blocks or within void
> procedures.
> >> >
> >> > Repro:
> >> >
> >> > -- Run this on a standby
> >> >
> >> > CREATE PROCEDURE test_wait()
> >> > LANGUAGE plpgsql AS $$
> >> > DECLARE
> >> > result text;
> >> > BEGIN
> >> > WAIT FOR LSN '0/1234' INTO result;
> >> > RAISE NOTICE '%', result;
> >> > END;
> >> > $$;
> >> > CALL test_wait();
> >> >
> >> >
> >> > The WAIT FOR itself succeeds, but the very next PL/pgSQL statement
> that requires a snapshot crashes the backend with:
> >> >
> >> > TRAP: failed Assert("portal->portalSnapshot == NULL"),
> >> > File: "pquery.c", Line: 1776
> >> >
> >> > Attached patches for both the test case and a potential fix. Please
> review.
> >>
> >> Thank you for reporting. But I doubt the fix is correct. Even that
> >> this particular might work OK, I don't think it's safe to release
> >> snapshots belonging to functions/procedures: it might affect them. I
> >> tend to think we must forbid wrapping WAIT FOR LSN with
> >> functions/procedures. I'll explore more on this today.
> >
> >
> > Agreed, attached a v2 patch with your suggestion on preventing it running
> > from procedures.
>
> Thank you. I've slightly revised your patch. I'm going to push it if
> no objections.
>
LGTM, thank you!
view thread (11+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures
In-Reply-To: <CAHg+QDd4NK2zjW6hPmS+Xr9UUdy+DAtywHeQhvcG+BXBEX0nEA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox