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 1wXFs1-0039m3-1O for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 10:09:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wXFrx-00AXOA-32 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 10:09:09 +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 1wXFrx-00AXO2-1y for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 10:09:09 +0000 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXFrv-00000002JK0-0oGg for pgsql-hackers@postgresql.org; Wed, 10 Jun 2026 10:09:09 +0000 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-7e266714bd3so73461887b3.2 for ; Wed, 10 Jun 2026 03:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781086145; cv=none; d=google.com; s=arc-20240605; b=WsAqoK2aLILLVTllO3N4IX0XWRkhYKSbDR4XBm7XaX5QEpdQ95gbzVXqhEi6BRGuPW lIgz3PSPARTubtjI+X9NDhFuDPTXWq1oQ3O3ZtLy0PKr3XhCvY1xBUn9EYpoF9ynZch5 DHcMlzPtvLUEpncsG+XpP+xAKztAWOyc6zxRneTf4Md70GE8I6mQzTEEzYGuwSMm35hV i8U9uD+hKAHKY1iFs5VYOz0G4+QBv4qXS6npipXss6pY/exo32dJvVdjISUc/lAeRT1/ 43CxTOYQbiDRmr06BbldgDPQnFCjEEZCSvy+mLGM3Om1wJ3DQFCoYM6+R9nx35aWu+Vg GGDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=fxDT0xSzIDNmtQYYhvrNWwlSJ5y/e/pYqQtKvCGx3jo=; fh=UyVX1ovHLjHAO1S9VCmZpHPYWhR5oQ8iJYyg4+Tla7s=; b=diNnMUFy1g4sKrgTJGa/A3YpLUrPRvaORtJCPNSfOvVcIfYFgZEDMJQRW5mFo9l0tg G8qFvEiDsx8RWgqYXE/zRF4Y9aGunjMajuJvy2Gmu0r2KveVLKfr4Q7ctl/pV3eUmau3 akTdlmDy7Y6Cd21lA9cLOfB3RLm9hn9ukuMCVaxoIeZ1QAbYJ5IsM2X/izV2/fob7AtT 8H6t/4gl2ZWmcKgqKOk7alookEsoNWyOdPzGtJEv2kk+TA4hE1fJocDa1XbA8ZWNdWR+ MHv/Q17Tiqn0gG4WlWtiz6XBn9sSa6GTFv+03NjYhJ1cAI28QOkGYhsyTfhlGAP/FvM+ OCTw==; 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=1781086145; x=1781690945; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=fxDT0xSzIDNmtQYYhvrNWwlSJ5y/e/pYqQtKvCGx3jo=; b=aeAtedoY/GvYY/BZQS2lpNrc9jgElthstDka0YnTypB6IMPRvHxo58AcxcGCX+Jw5i EfE/lF1iQUBNoyBXRxVHcXbtNQpU2nlWOwPDKsMQ54f9BRJ36VXV1yqFGgx/G478htgl 1jcfw3HKrKkbaydkBal7kvk23ju9evBrIHcRlVoJ9VKrr+t8v0UzHpRJ5EpQaEla8N1V CE/VbVUUeoRWxZi1S/ioeNJriOYbs+wFk0/YIHEYS/uShI5xcvCCocu7hy0UksNVNWRe JZkrvo+vkUFDkXSUda/GDdniSpctYJ4KLHu7cSxUSkOSTBuEDEnSBv6pEaflDUQvabSB safw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781086145; x=1781690945; h=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=fxDT0xSzIDNmtQYYhvrNWwlSJ5y/e/pYqQtKvCGx3jo=; b=ktX1OqY+DKFcb23VAVP+c5OVx5gxPAUdwgWpbFFLq9EZhtGJNVwGO/nyxPcU5AYU4a Ivc/ubMQnlQd+vdaNId3H0U0uUqLeFBnSdsGa63Q1Ngj5uh3J62vmuxvkWfPjMLd+gVr A6CMHST/2Sas+jTJHVwZfTJeTSSDo+seGRooYWuWHtnva9LSbA7raDBuQXAR3Fb96uqt 6CPCkW9QxXPIwX9+effGiSkxtosm+ig7KAGbqOfioSvqMw/h7AA1EJyVopceYbKeJ54k 6Otfn4LR6RsVBL/8mD5n9NkWuWp9Xv13fFH3KnbpYDFOBQrvll+fnPPV53ljAs4m3sgy vOLA== X-Forwarded-Encrypted: i=1; AFNElJ/Nu6w2qWFAcZWSMlwZy1yvpLJkCh2bCJ3O9mRB16VEkF1K3eTJOc8atDjm12ap2kvLgLVCbRgSkoGltp2p@postgresql.org X-Gm-Message-State: AOJu0YwtOSVWgxjbY+qiXuo6Vavhg5Jf7OUGU+tIIodRv30JfPLRqj9Q 6X3WHEmjLoAKJLFgRiuGCCGkKJAHs9NUCUw1pkHB+9gg/TCGdmoPC/thdGeZHMLkeJhhT2JaKjW i0rNiHsTToXJHomyUJ2pmrCC9qhokpOk= X-Gm-Gg: Acq92OEqPsWRXqrxgXmG4MABjTLqbrtHsBA9nmnxUJD0gz8pFty47AXtxiGKFPbzGb3 DwodwTq5YfD2AIsBrbKD34yL1L9ipg/jsBtCSFnMHk0vEz4XK9ibUUjSuxmlS918BILreOAx36V NePTCcEqT+xQKLqTdIeisVTHYx1dXxSLKrtRD1I6uEO8htBUyyUFJGmsHFlCBKdrumI3VCkSU0X cuyBalKJs3MHzGtTmgqG+W1SRXQeaUufuUypCdcDggrMDsphdE0tTb0zsuFKmnAIZeF2xqV7ak4 gNu75faZk5YaGjxK X-Received: by 2002:a05:690c:4b0a:b0:7cf:a117:4ec8 with SMTP id 00721157ae682-7ed0f434caamr248754537b3.38.1781086144537; Wed, 10 Jun 2026 03:09:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ayush Tiwari Date: Wed, 10 Jun 2026 15:38:53 +0530 X-Gm-Features: AVVi8CdcuCdLoqS7oA2XtDkWf1xLIyFe2ac9EkU5M_MsVVU1M_7BPi7tGTR0dFI Message-ID: Subject: Re: PG19 FK fast path: OOB write and missed FK checks during batched To: Amit Langote Cc: Nikolay Samokhvalov , pgsql-hackers mailing list , Andrey Borodin , Kirk Wolak Content-Type: multipart/alternative; boundary="000000000000f5a70c0653e36e8f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f5a70c0653e36e8f Content-Type: text/plain; charset="UTF-8" Hi, On Wed, 10 Jun 2026 at 14:02, Amit Langote wrote > > Thanks for checking. I will review them a bit more closely before > committing by Friday. Other reviews are welcome. > Thanks for the patch! I read through v1-0001 and v1-0002 and tried them locally. I had a couple of things I wanted to ask about. 1. The per-entry "flushing" flag and test coverage. If I'm reading the two patches together correctly, with both applied the 64-row re-entry test in 0001 reaches the flush through ri_FastPathEndBatch(), where 0002's cache-wide ri_fastpath_flushing guard already routes the re-entrant check to the per-row path before it gets back into ri_FastPathBatchAdd(). Does that mean the per-entry flag from 0001 isn't really exercised by that test once 0002 is in? As far as I can tell you'd need the flush to fire from ri_FastPathBatchAdd() itself (a 65th row) to reach it. I tried a 65-row variant (same FK, re-entrant DML from the cast during the full-batch flush), including a case where the re-entrant row was an orphan, and it seemed to do the right thing; the per-row fallback still raised the violation. Would it be worth switching the test to 65 rows, or adding that variant, so the per-entry guard is covered too? Or am I missing a path where the committed test already hits it? 2. Resetting ri_fastpath_flushing. I noticed it's cleared only in the PG_FINALLY of ri_FastPathEndBatch(), which does seem to cover the cases I could think of. Since ri_FastPathXactCallback already NULLs ri_fastpath_cache and clears ri_fastpath_callback_registered at transaction end, I wondered whether it might be worth clearing ri_fastpath_flushing there too, just as cheap insurance against some future path that leaves it set across transactions though maybe that's unnecessary given the PG_FINALLY. Other than the above queries, the patch looks good to me. Regards, Ayush --000000000000f5a70c0653e36e8f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Wed, 10 Jun 2= 026 at 14:02, Amit Langote <a= mitlangote09@gmail.com> wrote

Thanks for checking.=C2=A0 I will review them a bit more closely before
committing by Friday.=C2=A0 Other reviews are welcome.

Thanks for the patch!=C2=A0

I read through v1-0001 and v= 1-0002 and tried them locally.=C2=A0I had a couple of
things I wanted to= ask about.

1. The per-entry "flushing" flag and test cove= rage.=C2=A0 If I'm reading the two
patches together correctly, with = both applied the 64-row re-entry test in 0001
reaches the flush through = ri_FastPathEndBatch(), where 0002's cache-wide
ri_fastpath_flushing = guard already routes the re-entrant check to the per-row
path before it = gets back into ri_FastPathBatchAdd().=C2=A0 Does that mean the
per-entry= flag from 0001 isn't really exercised by that test once 0002 is in?As far as I can tell you'd need the flush to fire from ri_FastPathBatc= hAdd()
itself (a 65th row) to reach it.=C2=A0 I tried a 65-row variant (= same FK, re-entrant
DML from the cast during the full-batch flush), incl= uding a case where the
re-entrant row was an orphan, and it seemed to do= the right thing; the
per-row fallback still raised the violation.=C2=A0= Would it be worth switching the
test to 65 rows, or adding that variant= , so the per-entry guard is covered too?
Or am I missing a path where th= e committed test already hits it?

2. Resetting ri_fastpath_flushing.= =C2=A0 I noticed it's cleared only in the
PG_FINALLY of ri_FastPathE= ndBatch(), which does seem to cover the cases I could
think of.=C2=A0 Si= nce ri_FastPathXactCallback already NULLs ri_fastpath_cache and
clears r= i_fastpath_callback_registered at transaction end, I wondered whether
it= might be worth clearing ri_fastpath_flushing there too, just as cheap
i= nsurance against some future path that leaves it set across transactionsthough maybe that's unnecessary given the PG_FINALLY.

Other tha= n the above queries, the patch looks good to me.

Regards,
Ayush=C2=A0
--000000000000f5a70c0653e36e8f--