Re: VACUUM/ANALYZE double-count the backend's own pending table stats

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: Staroverov Ilja <i(dot)staroverov(at)ftdata(dot)ru>, Sebastian Webber <sebastian(at)swebber(dot)me>
Subject: Re: VACUUM/ANALYZE double-count the backend's own pending table stats
Date: 2026-10-15 07:11:27
Message-ID: 179204828715.3237120.899220695784427126@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Ilya,

> about the two pre-existing TRUNCATE/subtransaction cases: yes, please
> send the repros.

Attached: p1 and p2. They reproduce on 14 through master, and neither
patch changes them, so they aren't from this one. Agreed they're better
as a separate, back-patchable patch; I left the probable fix area (the
truncdrop save/restore across subxacts) in a comment, no fix.

> Manu, if you had a way to pin that one too, I'd be glad to use it.

I did find a deterministic one (diffs attached, works on 14..master and
also catches the ins_since_vacuum case), but let me be upfront: it's
unconventional. The test function is marked IMMUTABLE only so it can be
indexed, and it does DML during ANALYZE (an armed expression index
inserts into the table whose TOAST the same VACUUM then cleans). A
committer may not want that in a test. The clean alternative is a
test-only injection point in the flush path, but that's a core change.

My honest lean is the injection point, or just leaving the VACUUM case
best-effort as you have it, rather than the index trick. Your call; the
diffs are there if you want them.

Regards,
Manu

Attachment Content-Type Size
p1_repro.sql.txt text/plain 1.7 KB
p2_repro.sql.txt text/plain 2.3 KB
vacuum-pin-0001.diff text/x-patch 6.9 KB
vacuum-pin-0002-tests.diff text/x-patch 2.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Staroverov Ilja 2026-10-15 07:48:32 Re: VACUUM/ANALYZE double-count the backend's own pending table stats
Previous Message solai v 2026-10-15 06:29:00 Re: BUG #19670: Silent Integer Overflow in time_pl_interval() Returns Wrong Time Value