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 1wB3NX-000gxL-0o for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Apr 2026 04:21:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wB3NV-009Fmd-1r for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Apr 2026 04:21:58 +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 1wB3NV-009Fm0-0y for pgsql-hackers@lists.postgresql.org; Fri, 10 Apr 2026 04:21:58 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wB3NT-00000000ICJ-3o91 for pgsql-hackers@postgresql.org; Fri, 10 Apr 2026 04:21:57 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2aae146b604so11743425ad.3 for ; Thu, 09 Apr 2026 21:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775794914; cv=none; d=google.com; s=arc-20240605; b=L7wSmQJ6UgzitxnkydH+nlXXeTHoUJq0uZ0pBAugO8dkiUfYeLeTSt55TfQAd8DdeH McxcSG2SkELb2iBdfLL67vCmnNKgMiUAn9dnTuqs3oxA/wd/GuuHCeIACnFCLPvqWPhb TLeVyPIs7pYpEZbMTidbfMFzChsKllVWI4+f+t9bX2Jqru8u4XXa1QOSfcpkssKrNeaf DLZw/9cB/E6g6B+9rwOvTBlazCn0CmQZWc90R1UbjuzRFLMelRa8xw9UolO5DuDALwmh Vm1hm58Qrk5cfqPJF0JYa2AferA9TiU0UgdtpSZ42Ak++1dCS2EA9bVqqfjmsDYzRbs4 /XVA== 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=MdsEQr6JV4wQmClAlCT3xvlYm2sYb0ZyVoPnSFSB1S0=; fh=hAfk1wjeZjaTQZSIhZYdgrFz19RYQJBFiLAWvnjZP9k=; b=GzjGC0qyFHw43RbU2TfFxk5heYksZ1VnFRKlCB8uOfjY0/dHRh7Aqq+aqWkkZqsAE9 3t7ZiGX92D4+EQHlChgzxgp8c7AJfM2cthIZXwl1qRqM4eij2e/Yoh8rIASoKPiLp8qX PGY8BLPcGdu21D5LdNmQ5b/SD7XWerBvvlQhKD2ibe/B6r9JWrh6q8UEeJOgArCDFRwY 8z3xhtA/+wQmDshf1t/KsdEuyw/+SqrSzxGqU3zLiTuf+BafPRrJ7gmhMrCqm7uNDM/e HnSfROPNXK4rtjbIRGedHPjQS7mBAjCB1ATCVNVu0CPWqZ91qBzmQ/lQ3DaubmDZUEHh 5AkA==; 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=1775794914; x=1776399714; 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=MdsEQr6JV4wQmClAlCT3xvlYm2sYb0ZyVoPnSFSB1S0=; b=nq1V0d1T5Lj6MGivFcDaZ59ECIq+Fullim43KGLVl77npEIGjIy/mio3CM/j0AO2eM ASvkbm+U3rd/RGn/uRLvPQJn3BPFLOSVEwJq5tIglVFqFacUl8zrOuROL9deicZ78Sa0 nK4AlPBqARGKq4z2bI2VLhRxxl+njjXhP99Ca/hl6GZQjdOJriZpUaQTW5elD1MXCXZF uB0fGtpJ/vGxyheXNgmvRL0m6eFulnfznP/Iz5aYt302HRNM+Rf53qSLZOnA3bPAbtqH XKmtyhVhq1F5h1jDRrK7+pyxpy6+ADbz58+JKMPobCzf8NV85CH5tyBf8+bGGWgT4Bkl vWwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775794914; x=1776399714; 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=MdsEQr6JV4wQmClAlCT3xvlYm2sYb0ZyVoPnSFSB1S0=; b=NyjohlQoze4DQa92pREz9NWAtGzCpsioUEo74Z9fS7FqIKHqU8Ycs5BwLU2jiyonHx ZzRWwAt1qZwYwk9mjMeoFJKp9Zt4nqPklbsdR0NnxYM/DQYko+rwwkqDlnb6jkCDIaye Qunt6/ZnQUnxPKTxOlHapd9KeKYFmyOP+W6Ki4998XtrLJFGwsRH7yCamO7cDkbowN7L LiIlxv6BYlsZgZkijqXjnHyQN8IpJW/AfOcTMJbY2ShMjhB7btWQ34lVJ88xpOVMIMgx 7gp9VfMksquhuFfW6OUT5GAKSp7u8AeLFPN9KTLeAOcvP3eVOMIvs7LTVL/V6ziITuDH tnPQ== X-Forwarded-Encrypted: i=1; AJvYcCWHGF/HLSr5m/5BCaesIMsGimsdqyvQiq/AeQcZlyZbLcM3fz06+fTSjw0cZgjWgxJT9UTJWDdi8KHeuori@postgresql.org X-Gm-Message-State: AOJu0Yyyq/1GjVMueJgTL8DpmruMAAj8imCftfj0hY6fFIYTJjoayGBl +FMHqiaNtktFSRXG3xFU71yrcWlJVJj1kTGzmCIaT32udfA8sT0Qiu6UrBKAmPVT85xqwHzOhME lgSnuKZEy+yZO7uvyFMn8eNIRKAcvmbM= X-Gm-Gg: AeBDiev7Yt6PbU49CTehNl0Ya71XCFmhgCXJTjsJ6IXadEIGESb8uW6576aHdmJF1uW i6j/AOhZ4vOp9kLL1+hLT16qdAj426tSuLALGmfK2TE5PjzaxayHqW6b7HzC4rbFpc3kgg932gL UlFgcXp4CLS4QsXI4AfPr5xyE0DHNMYTMKh1DZ3w+xQPkFrrph8OkSjBR4LDT9YPMlVtc+31CJ8 F1eNoL+QFCECuqur2DQuMdzQJ+HrnK/Lc888B1lDuimhtIwiXdnGAa6H3w3bavnzemKUP79Bk7P 9Q1ME7utnHRTi22YP5EsR+X239UmEDAycztAU7j89HbAkHByEa2D6S5XpOPfHN0r X-Received: by 2002:a17:902:f98b:b0:2b2:cfdf:10f2 with SMTP id d9443c01a7336-2b2d5a384f1mr11129105ad.20.1775794913943; Thu, 09 Apr 2026 21:21:53 -0700 (PDT) MIME-Version: 1.0 References: <43b56e3b-80d6-4a45-a313-cb1caa587b22@vondra.me> <1290fac7-8430-4d2c-bfcb-00c65adff5e5@vondra.me> In-Reply-To: From: Amit Langote Date: Fri, 10 Apr 2026 13:21:37 +0900 X-Gm-Features: AQROBzAXSWmaqApKh6jDDqQ5lR4YLkYWJhWhtKaeMDYFAoNZljQYm41pGVyRssM Message-ID: Subject: Re: Eliminating SPI / SQL from some RI triggers - take 3 To: Chao Li Cc: Sandro Santilli , Tomas Vondra , Junwang Zhao , Pavel Stehule , PostgreSQL-development , jie wang 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 Fri, Apr 10, 2026 at 1:21=E2=80=AFPM Chao Li wr= ote: > > On Apr 10, 2026, at 12:14, Amit Langote wrote= : > > > > Hi Sandro, > > > > On Fri, Apr 10, 2026 at 1:02=E2=80=AFAM Sandro Santilli w= rote: > >> On Thu, Apr 09, 2026 at 08:55:01PM +0900, Amit Langote wrote: > >>> Hi Sandro, > >>> > >>> 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: > >>>>> > >>>>> TBH I haven't noticed the memory context issue myself, I only notic= ed > >>>>> because the builds with index prefetch started crashing. > >>>> > >>>> We're getting a crash in PostGIS too, since that commit was merged i= nto > >>>> the master branch, see https://trac.osgeo.org/postgis/ticket/6066 > >>>> > >>>> The crash is triggered a C function using SPI. > >>> > >>> Evan Montgomery-Recht posted a report of the same issue on this threa= d > >>> a couple of days ago. > >> > >> I confirm the patch attached in Evan's email [1] fixes the crash for u= s. > >> > >> [1] https://www.postgresql.org/message-id/CAEg7pwcKf01FmDqFAf-Hzu_pYnM= YScY_Otid-pe9uw3BJ6gq9g%40mail.gmail.com > >> > >>> I have posted a patch to fix the issue, which I will commit tomorrow > >>> after a bit more testing. > >> > >> 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 ! > > > > Thanks for confirming that. > > > >> Let me know when it is time to test again against master. > > > > I have just pushed 0001 which you'll find in master as 34a3078629. > > > > -- > > Thanks, Amit Langote > > Hi Amit, looks like you missed to fix the typo that Jie pointed out. In 3= 4a307862930056e1976471d6d81a5e2efc148df, > ``` > + bool firing_batch_callbacks; /* true when in > + * FireAfterTriggersBatchCallbacks() */ > ``` > The typo is still there. Yep, my bad. Will push a fix shortly. --=20 Thanks, Amit Langote