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 1wB3Ml-000gvv-2j for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Apr 2026 04:21:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wB3Mj-009Dgc-0b for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Apr 2026 04:21:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wB3Mi-009DgS-2k for pgsql-hackers@lists.postgresql.org; Fri, 10 Apr 2026 04:21:09 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wB3Mh-00000000IC6-1tuf for pgsql-hackers@postgresql.org; Fri, 10 Apr 2026 04:21:09 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-35d971fb6f1so1499752a91.0 for ; Thu, 09 Apr 2026 21:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775794865; x=1776399665; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MVnNuD6i37M7bS95o4cax0e3W4SPKLUHnuIb3892t9w=; b=FjBsjA9ik89P7Fx2eS+Vv2qbLdlOsDO/VNXZMdGZQHdoCY9dQtnAaohNbsINXhe4cy dLuXXdv5LdCWB8lOlnHdi10pkDMoxtQxPdsFjwmq/Eldsnj4BgLQ+qsg44viyChW2cTM GqO4FYxSQacLP9tYMhXzldXQbMpMFY/qVr6mCqlmNU2GpyyoO2hlJIKLrfzZmnnfIyCs RaaKj7dvzJROKb+4LhPrktJ336rP7BG9gOyXez9j+64Ceow6RyBbnP2BerlkjYyPAV6I Yst+E/bmeNC8ZZa63ZvuZCqYUu/1kBC6tFhE1HA+HCDTiNnM3CXxgvclDd5tBhmHu3bm xNlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775794865; x=1776399665; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=MVnNuD6i37M7bS95o4cax0e3W4SPKLUHnuIb3892t9w=; b=bgq7EsPKf2sFuvsqGePQscydkYiAbrr5xRf3xSeAeGvZU+By+R3l31I1SNDphkf1mD ING2/35nLP8vtYRqxISeFelc38HoyeV2p41Z1NJk0W5o0hZwsLPnIEuMleFPd62SHLh3 JYQZ7wKXtEO/NOQM7WC9Q1MdYtFVNmIsA/aBKHzxPpZpyaRb8XKGEAKja7f6NTr3B2RJ vFsaVMTxo+kK1+YBwclOun/btl8kR1Y93jtcUcBVTduAs4c8cQ88uF6zZy4o89FgO6db SYQl3FFUps43RXH6mGYtW93mxJUQS2nmS9G8/KL+5VV2y2GtxV64yRLbaHXSiXsHdaGr bnaQ== X-Forwarded-Encrypted: i=1; AJvYcCVE7ZnSk1MHOu/D92CO8p1lQdwdsxijyxhKmuAzzSypP4oUNcFHq3Ce3YZmP96BbySvVb3s8VOzghgLf/KZ@postgresql.org X-Gm-Message-State: AOJu0Yy9X+NI3dyCnw3gL/RAZcZX7QkFLkQQAV0ZL9xzR+UtOPDitqVN n3xVoyT4d9O6WFctmP+LWVhZm66aJt1dOdOWORgmsDwd9u8PE9g6JAU5 X-Gm-Gg: AeBDiev822XlHDcWlLAKcIemLchY4R/cEJudDolOGI+LRnJ7ZOk8kR1ptuapgSkMG18 zzzi2vpCjsCRD02n1JecdTTAEPvZJDtA1kX+SohYbiv7TDvUlc5h9yDXb3IOA5U9C+lN5XOi8L6 NVPENCtje0g9WZYEihTJqdcJDz5w3pnWVJyonPp/AOqAtOBXM1Fqk7FS1mMaes5Ecg8MPMcir9s durpl+OWh3+T6MOhtA9MrGZz+Z3lqwJINKTeiWOKg42wYerauDYVR11NL/ODZFHGOauV+zfaR9z CGXuB9R4U/abpbg2cfUK2NppQe/c9YqwVeMwQZ7i3aqGC47+jtsPvb8Gu2NoMisHluIzFJ2XUKI AsQTgR7xXG7yIAfde8VWUJQLoif2Zk8GatqSc0mnqt6qg+kmEIUhpfDUbnF9FJ/NVOhgySjAU3g LumX26BvHHTK49w1wBUM0PKTvmuq2l2j0= X-Received: by 2002:a17:90b:4b0e:b0:35d:9d4f:f595 with SMTP id 98e67ed59e1d1-35e4282beecmr1771387a91.17.1775794864978; Thu, 09 Apr 2026 21:21:04 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b2d4f25df6sm12390975ad.56.2026.04.09.21.21.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2026 21:21:04 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Eliminating SPI / SQL from some RI triggers - take 3 From: Chao Li In-Reply-To: Date: Fri, 10 Apr 2026 12:20:24 +0800 Cc: Sandro Santilli , Tomas Vondra , Junwang Zhao , Pavel Stehule , PostgreSQL-development , jie wang Content-Transfer-Encoding: quoted-printable Message-Id: References: <43b56e3b-80d6-4a45-a313-cb1caa587b22@vondra.me> <1290fac7-8430-4d2c-bfcb-00c65adff5e5@vondra.me> To: Amit Langote X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 10, 2026, at 12:14, Amit Langote = wrote: >=20 > Hi Sandro, >=20 > On Fri, Apr 10, 2026 at 1:02=E2=80=AFAM Sandro Santilli = wrote: >> On Thu, Apr 09, 2026 at 08:55:01PM +0900, Amit Langote wrote: >>> Hi Sandro, >>>=20 >>> On Thu, Apr 9, 2026 at 8:07=E2=80=AFPM Sandro Santilli = wrote: >>>> On Mon, Mar 02, 2026 at 01:34:41PM +0100, Tomas Vondra wrote: >>>>>=20 >>>>> TBH I haven't noticed the memory context issue myself, I only = noticed >>>>> because the builds with index prefetch started crashing. >>>>=20 >>>> We're getting a crash in PostGIS too, since that commit was merged = into >>>> the master branch, see https://trac.osgeo.org/postgis/ticket/6066 >>>>=20 >>>> The crash is triggered a C function using SPI. >>>=20 >>> Evan Montgomery-Recht posted a report of the same issue on this = thread >>> a couple of days ago. >>=20 >> I confirm the patch attached in Evan's email [1] fixes the crash for = us. >>=20 >> [1] = https://www.postgresql.org/message-id/CAEg7pwcKf01FmDqFAf-Hzu_pYnMYScY_Oti= d-pe9uw3BJ6gq9g%40mail.gmail.com >>=20 >>> I have posted a patch to fix the issue, which I will commit tomorrow >>> after a bit more testing. >>=20 >> I also confirm your patch = v4-0001-Fix-RI-fast-path-crash-under-nested-C-level-SPI.patch >> fixes the crash for us. Thank you ! >=20 > Thanks for confirming that. >=20 >> Let me know when it is time to test again against master. >=20 > I have just pushed 0001 which you'll find in master as 34a3078629. >=20 > --=20 > Thanks, Amit Langote Hi Amit, looks like you missed to fix the typo that Jie pointed out. In = 34a307862930056e1976471d6d81a5e2efc148df, ``` + bool firing_batch_callbacks; /* true when in + * FireAfterTriggersBatchCallbacks() */ ``` The typo is still there. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/