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

From: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>
Subject: Re: PG19 FK fast path: OOB write and missed FK checks during batched
Date: 2026-09-15 09:00:46
Message-ID: CAM527d8ROO1mv28nMDKdDojMgdo1ys25+0L2spzyicUCkGBm7g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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,
Nik

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Osama Abdul Qader 2026-09-15 09:15:21 Re: Severe performance degradation with concurrent updates due to excessive EvalPlanQual (EPQ) re‑evaluation
Previous Message Nikolay Samokhvalov 2026-09-15 09:00:34 Re: [PATCH] Invalidate cached plans when casts change