| From: | SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com> |
|---|---|
| To: | Alexander Korotkov <aekorotkov(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures |
| Date: | 2026-04-09 02:03:31 |
| Message-ID: | CAHg+QDcN-n3NUqgRtj=BQb9fFQmH8-DeEROCr=PDbw_BBRKOYA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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 | Content-Type | Size |
|---|---|---|
| 0002-Add-regression-tests-for-WAIT-FOR-LSN-inside-PL-pgSQ.patch | application/octet-stream | 2.1 KB |
| 0001-Fix-assertion-failure-in-WAIT-FOR-LSN-when-used-insi.patch | application/octet-stream | 2.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Yogesh Sharma | 2026-04-09 02:04:50 | Re: Optimize SnapBuild by maintaining committed.xip in sorted order |
| Previous Message | Chao Li | 2026-04-09 01:51:26 | Re: pgstat vs aset |