Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures - Mailing list pgsql-hackers

From SATYANARAYANA NARLAPURAM
Subject Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures
Date
Msg-id CAHg+QDcN-n3NUqgRtj=BQb9fFQmH8-DeEROCr=PDbw_BBRKOYA@mail.gmail.com
Whole thread
Responses Re: Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures
List pgsql-hackers
Hi hackers, Alexander,

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.

Thanks,
Satya

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: pgstat vs aset
Next
From: Yogesh Sharma
Date:
Subject: Re: Optimize SnapBuild by maintaining committed.xip in sorted order