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 1wAj2q-000GS6-0f for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 06:39:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAj2o-0041cb-1T for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 06:39:15 +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 1wAj2o-0041cB-0U for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2026 06:39:15 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAj2m-000000007Ym-1Yha for pgsql-hackers@postgresql.org; Thu, 09 Apr 2026 06:39:14 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-66c05fb27e4so929263a12.2 for ; Wed, 08 Apr 2026 23:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775716751; cv=none; d=google.com; s=arc-20240605; b=KmqI8PWSvhYkokRL6DLP38Lkl/5uhlz4gvsQbvCHkQIJeXy6u3gkrmaHvLoAnVvfIn REgnTv0TskVMfHEVFioRA8XGuJGnY4vnXGZuiYO2PPQoOQt9XGhAcMLRR/TmQYgDMd69 mjuAnrANt/ddNN8RNJYf8irMc/Lmf9uEyzF1E8mlhvPD2aWcnZfcmlrgNnvMFrE6UoXG oohijAU04njJ0aDYl1i17uNFShY7G/VYyZAZ3Kvj5zkillZrl4S7CnoJS+FXIRB2VMI9 jiDWIDv5KbEetFOFyFHOt36krQtwctXPTYVF8rW/+m/a4PDewO59/Wgn5IFURk8MEZWJ 0Trw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FTnATBRLNE+8sxBZtCVgxc2/ScdZ0eWXwZ6HKwCRb/U=; fh=uBF79l2oU+xEcUI3oJKWonq/GNeTm67zQeQfTQlK8wQ=; b=dNdg7hoR7zo6b+Lq0TWdmdlFDrfvMsoqLhJAZfpZglZAkKvfHqoW2l1ef7Qhqlq92V WBW8IIuqFhRwkzYG1L/i9KFmOSjpPt4eDGf9QuYQaS2ctw7rN2GV5BUr0atJrZZTkbi2 xBOz707/BBLDg7xL26urQbudFLxE8GMia0dj5CaAZCF2gCcbpA7sYexIGBGEaXYhia0A wvfAb1kk0kfbmiwh6sIUyCFkuKh/b43HbSPzXn12pK+iLCT4+m3NyO1K0RCV7DF0ylcC lNzHh9IIkT8fVWIZwdZ+IqHt5N/WuUqHRpulODtKgGyzd92bCO4Zhjd72I8vIZ0pMmHV hrQA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775716751; x=1776321551; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FTnATBRLNE+8sxBZtCVgxc2/ScdZ0eWXwZ6HKwCRb/U=; b=VBGxR2G7yw3c1sQuhfNk0kpbyu0zrk2FXUGZOZrRE/ImdTEmnBgCX9E4kn0r8c5SEU zlyGgyP9MYjG1sYfKnNamielCWbtm4rx44ZvLqUK6eEqyAgGhb/OLkUIrMddX35WEHdZ RZ2KDc7qA6WfBRdIzvssPLdQdLVJdWTDmitwgV0uIpT448kBlHrOD4eX64VMznkziNQy 2bRwonm/S32hOehVMvAsJKFk4MwktNs36zM8FEFOSePPrCRJmALjnKN5icxamhoYKid0 Zm26LDqoptgMDfAg9VS/2cDycmAq0Viv1dB9xKWbdVBLM1GR/LRpJVxbbtW0MJ21MoE9 0aPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775716751; x=1776321551; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FTnATBRLNE+8sxBZtCVgxc2/ScdZ0eWXwZ6HKwCRb/U=; b=X0MiAsajbgTM8B6wXxy973w6EuraX3bOjN5XHCb9lowHnt8ZUiqE9qhumDg7ro67f+ VUqA7C3hxn/QKmegiGnhTnc3zEfgBm7khkEMgPupYgUCIt8CPy/T2rpsVGVcb02OhxQd RPTJ+J7IGTfyTepOjlt37sqs+xLCKlO+FJGgLqo57CsqB6GNXexXzroY/Cqk/ZFCdTef WI7d4ZR3D0tyscPH37QmKBW/puYSE87+9LswadOHDseQfhehe8VD41Uyo9Mwo2TeTK5E WzgfarYSpU+C8GnmB/sngwbDSPke9L5txSIU44C4oUCsCVHS8G5MAKNO/o4wL/fvqG12 i4kw== X-Forwarded-Encrypted: i=1; AJvYcCU1R9BMOa2x9HnB/Q1/ii0oKjnhLRQb8VpVwNGa2ERCZgeG/2hyHqjJVxjRTg7VPPM4NYpjraIITaA5fJsu@postgresql.org X-Gm-Message-State: AOJu0Yz1VHrzIC8X1HEi+y02/v7CoLnuqOHMuq9CXADYBKEKa//sFE3G 4ulqjzuuW+BoOh2Mp3Qo8sFkSMWM9RBJxjI5c4GJIO/4+6EDngOu+thef0mDHtgMumq9zZVZy9T lDi4gooE+hzL06N2JqeqLNnxqV+dfPJM= X-Gm-Gg: AeBDieuVBLEgy+CrFxaI+2ZN2IUw27FFZaQ5QL/rlIs0nMH+mTYjGPnOrA+dMylgPQ6 YoQpMwiQn54VXa25jDta0vsopaVYXUKIdNB0rVMkdIB+xU/TyJhRXGNQxUoj3kl+Z1fV8u/4fBH MBllm7YEGEktw8pOFe++8YcodYadYyWc+q+1+XkaRayM0dLzOIEvnAGiLG2C2WoF/Y5lM9WTrfP AwyGjJp7wGCQjvb3gjpV7LycH2b/EaO1LXKvTAkzp6O+EW58rpl4IwVKAkfIDt0ZjJGijNla1OE eNzlbKySmEnKkM15tIJtVUfJNY/zSpCF7pPzVkv+gP5YZnS1aUatGzadr7qTJAozKG/BdINuWb7 /0kCvL1ro X-Received: by 2002:a05:6402:358e:b0:66e:f4c0:c348 with SMTP id 4fb4d7f45d1cf-66ef4c0c5a1mr7374723a12.7.1775716751136; Wed, 08 Apr 2026 23:39:11 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Xuneng Zhou Date: Thu, 9 Apr 2026 14:38:59 +0800 X-Gm-Features: AQROBzBCimHvxSiQEY6lhpy_LAhy8Xhb9j8xJNm24PTDdLcJcpymwgP7yRwljFM Message-ID: Subject: Re: Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures To: Alexander Korotkov Cc: SATYANARAYANA NARLAPURAM , PostgreSQL Hackers , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 9, 2026 at 2:00=E2=80=AFPM Alexander Korotkov wrote: > > Hi, Satya! > > On Thu, Apr 9, 2026 at 5:03=E2=80=AFAM SATYANARAYANA NARLAPURAM > wrote: > > An assertion failure (server crash in assert-enabled builds) occurs whe= n WAIT FOR LSN ... INTO is used inside PL/pgSQL DO blocks or within void pr= ocedures. > > > > 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 =3D=3D NULL"), > > File: "pquery.c", Line: 1776 > > > > Attached patches for both the test case and a potential fix. Please rev= iew. > > 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. > --=20 Best, Xuneng