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.98.2) (envelope-from ) id 1xHjhh-00000003GtF-0fno for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Oct 2026 15:18:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xHjgh-0000000Evvv-0UEv for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Oct 2026 15:17:39 +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.98.2) (envelope-from ) id 1xHjgg-0000000Evvm-3SXk for pgsql-hackers@lists.postgresql.org; Fri, 16 Oct 2026 15:17:38 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xHjgc-00000002VUC-3kEI for pgsql-hackers@lists.postgresql.org; Fri, 16 Oct 2026 15:17:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 69GFHOeJ3043945; Fri, 16 Oct 2026 11:17:24 -0400 From: Tom Lane To: Amit Langote cc: PostgreSQL Hackers Subject: Re: Two more RI fast-path issues In-reply-to: References: Comments: In-reply-to Amit Langote message dated "Thu, 08 Oct 2026 12:58:00 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3043943.1792163844.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 16 Oct 2026 11:17:24 -0400 Message-ID: <3043944.1792163844@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk There is still something wrong in the RI_FKey stuff. BF animal trilobite reported a SIGSEGV in the foreign_key test, and I was able to reproduce that locally by compiling HEAD with -DCLOBBER_CACHE_ALWAYS. Stack trace looks like Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00000000007770df in _SPI_execute_plan (plan=3Dplan@entry=3D0x184fafc= 0, options=3Doptions@entry=3D0x7fff7819da00, snapshot=3Dsnapshot@entry=3D0= x0, crosscheck_snapshot=3Dcrosscheck_snapshot@entry=3D0x0, = fire_triggers=3Dfire_triggers@entry=3Dfalse) at spi.c:2498 2498 CachedPlanSource *plansource =3D (CachedPlanSource= *) lfirst(lc1); (gdb) bt #0 0x00000000007770df in _SPI_execute_plan (plan=3Dplan@entry=3D0x184fafc= 0, options=3Doptions@entry=3D0x7fff7819da00, snapshot=3Dsnapshot@entry=3D0= x0, crosscheck_snapshot=3Dcrosscheck_snapshot@entry=3D0x0, = fire_triggers=3Dfire_triggers@entry=3Dfalse) at spi.c:2498 #1 0x0000000000778030 in SPI_execute_snapshot (plan=3Dplan@entry=3D0x184f= afc0, Values=3DValues@entry=3D0x7fff7819db00, Nulls=3DNulls@entry=3D0x7fff= 7819dac0 " ", snapshot=3Dsnapshot@entry=3D0x0, = crosscheck_snapshot=3Dcrosscheck_snapshot@entry=3D0x0, read_only=3Drea= d_only@entry=3Dfalse, fire_triggers=3Dfalse, tcount=3D1) at spi.c:796 #2 0x0000000000a1565c in ri_PerformCheck (riinfo=3Driinfo@entry=3D0x183d6= 738, qkey=3Dqkey@entry=3D0x7fff7819ddb8, qplan=3D0x184fafc0, fk_rel=3Dfk_r= el@entry=3D0x7f4431f051d0, pk_rel=3Dpk_rel@entry=3D0x7f4431f08190, = oldslot=3Doldslot@entry=3D0x0, newslot=3D0x1847e5a8, is_restrict=3Dfal= se, detectNewRows=3Dfalse, expect_OK=3D5) at ri_triggers.c:2723 #3 0x0000000000a16026 in RI_FKey_check (trigdata=3D) at ri= _triggers.c:535 #4 0x0000000000a17cdc in RI_FKey_check_ins (fcinfo=3D0x7fff7819e980) at r= i_triggers.c:563 #5 0x0000000000702b6d in ExecCallTriggerFunc (trigdata=3Dtrigdata@entry=3D= 0x7fff7819eb50, tgindx=3Dtgindx@entry=3D0, finfo=3Dfinfo@entry=3D0x1821a62= 0, instr=3Dinstr@entry=3D0x0, = per_tuple_context=3Dper_tuple_context@entry=3D0x18198a80) at trigger.c= :2409 #6 0x0000000000704ed6 in AfterTriggerExecute (estate=3D, e= vent=3D0x181a2bec, relInfo=3D0x1847c9c8, src_relInfo=3D, ds= t_relInfo=3D, trigdesc=3D0x1821a810, = finfo=3D0x1821a620, instr=3D0x0, per_tuple_context=3D, = trig_tuple_slot1=3D0x0, trig_tuple_slot2=3D0x0) at trigger.c:4599 #7 afterTriggerInvokeEvents (events=3Devents@entry=3D0x180523b0, firing_i= d=3D1, estate=3Destate@entry=3D0x18218960, delete_ok=3Ddelete_ok@entry=3Df= alse) at trigger.c:4840 #8 0x000000000070a01b in AfterTriggerEndQuery (estate=3Destate@entry=3D0x= 18218960) at trigger.c:5222 #9 0x000000000072ff34 in standard_ExecutorFinish (queryDesc=3D0x18482ac0)= at execMain.c:454 #10 0x000000000092f0d8 in ProcessQuery (plan=3D, sourceText= =3D0x17fbc450 "INSERT INTO fp_reentry_fk SELECT row(1)::fp_vch FROM genera= te_series(1, 2);", params=3D0x0, queryEnv=3D0x0, = dest=3D0x184a2ba8, qc=3D0x7fff7819ee90) at pquery.c:190 #11 0x000000000092fbf6 in PortalRunMulti (portal=3Dportal@entry=3D0x180440= 70, isTopLevel=3DisTopLevel@entry=3Dtrue, setHoldSnapshot=3DsetHoldSnapsho= t@entry=3Dfalse, dest=3Ddest@entry=3D0x184a2ba8, = altdest=3Daltdest@entry=3D0x184a2ba8, qc=3Dqc@entry=3D0x7fff7819ee90) = at pquery.c:1273 #12 0x000000000092ffb7 in PortalRun (portal=3Dportal@entry=3D0x18044070, c= ount=3Dcount@entry=3D9223372036854775807, isTopLevel=3DisTopLevel@entry=3D= true, dest=3Ddest@entry=3D0x184a2ba8, = altdest=3Daltdest@entry=3D0x184a2ba8, qc=3Dqc@entry=3D0x7fff7819ee90) = at pquery.c:788 #13 0x000000000092be16 in exec_simple_query (query_string=3D0x17fbc450 "IN= SERT INTO fp_reentry_fk SELECT row(1)::fp_vch FROM generate_series(1, 2);"= ) at postgres.c:1297 #14 0x000000000092d9ad in PostgresMain (dbname=3D, username= =3D) at postgres.c:4946 #15 0x0000000000927d5d in BackendMain (startup_data=3D, sta= rtup_data_len=3D) at backend_startup.c:124 #16 0x000000000086fb7d in postmaster_child_launch (child_type=3D, child_slot=3D4, startup_data=3Dstartup_data@entry=3D0x7fff7819f300,= startup_data_len=3Dstartup_data_len@entry=3D24, = client_sock=3Dclient_sock@entry=3D0x7fff7819f320) at launch_backend.c:= 268 #17 0x000000000087331f in BackendStartup (client_sock=3D0x7fff7819f320) at= postmaster.c:3650 #18 ServerLoop () at postmaster.c:1727 #19 0x0000000000874c0a in PostmasterMain (argc=3Dargc@entry=3D3, argv=3Dar= gv@entry=3D0x17fb7e50) at postmaster.c:1414 #20 0x0000000000532488 in main (argc=3D3, argv=3D0x17fb7e50) at main.c:227 (gdb) p debug_query_string = $1 =3D 0x17fbc450 "INSERT INTO fp_reentry_fk SELECT row(1)::fp_vch FROM ge= nerate_series(1, 2);" It looks like something is not prepared for a cached plan to get invalidated underneath it. regards, tom lane