Re: PG19 FK fast path: OOB write and missed FK checks during batched

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PG19 FK fast path: OOB write and missed FK checks during batched
Date: 2026-09-16 02:50:06
Message-ID: CA+HiwqF-rPW-jLoXrai++FOfjzpy83tjZRycLimVA9JXa8_1pQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Nik,

On Tue, Sep 15, 2026 at 6:01 PM Nikolay Samokhvalov <nik(at)postgres(dot)ai> wrote:
>
> Here's the reproducer for the retained flush contexts. Run it in a fresh
> superuser session on master ceae3099.
>
> begin;
> create temp table p (k int primary key);
> create temp table c (k int references p);
> insert into p values (1);
> do $$
> begin
> for i in 1..1000 loop begin
> insert into c
> select case when g = 64 then 2 else 1 end
> from generate_series(1, 64) g;
> raise exception 'insert unexpectedly succeeded';
> exception when foreign_key_violation then null;
> end; end loop;
> end
> $$;
> select count(*) as contexts, coalesce(sum(total_bytes), 0) as bytes
> from pg_backend_memory_contexts
> where name = 'RI fast path flush temporary context';
> rollback;
>
> Before rollback, I get 1000 contexts / 16384000 bytes without the patch,
> and 0 / 0 with it.

Thanks for the report. I'm adding this to my list of batching issues
to fix in the master, along with the patches I posted upthread on Sep
4.

--
Thanks, Amit Langote

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-09-16 03:01:05 Re: SQL/JSON DEFAULT ON ERROR/ON EMPTY evaluation fail should rethrow error unconditionally
Previous Message Amit Langote 2026-09-16 02:47:51 Re: SQL/JSON DEFAULT ON ERROR/ON EMPTY evaluation fail should rethrow error unconditionally