Re: pgstat: Flush some statistics within running transactions, take 2

From: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Lukas Fittl <lukas(at)fittl(dot)com>
Subject: Re: pgstat: Flush some statistics within running transactions, take 2
Date: 2026-11-16 16:56:09
Message-ID: CAN12+Y+eB7DS3XSB98jAtvKEKavKjOxcx+_o=hZEjcYf=6tjKg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Attached is v20 which addresses the points raised by
both Zsolt and Bertrand above.

1/ CHECK_FOR_INTERRUPTS() is back in the flush loop, but only runs
when !xact_boundary, as Bertrand suggested. A cancel can still
interrupt an in-transaction flush, while the flush at idle can no
longer ERROR after the query has finished.

2/ n_ins_since_vacuum after TRUNCATE plus an aborted savepoint is
fixed. I added a test for this.

3/ n_dead_tup after a committed TRUNCATE + ANALYZE is fixed. The
flushed live/dead baselines are now reset at commit along with the
counts, so Bertrand's example shows 0 after ANALYZE.

4/ For the docs, I went with the commit message wording, as Zsolt
suggested, but made it precise. A released savepoint's counts still
wait for the top-level commit; only rolled-back subtransactions
flush early. The commit message is updated to match.

--
Sami

Attachment Content-Type Size
v20-0001-pgstat-Allow-pg_stat_force_next_flush-to-work-in.patch application/octet-stream 111.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-11-16 17:20:36 Re: Checkpoints stuck after a failed bulk write inside a savepoint
Previous Message Matheus Alcantara 2026-11-16 16:40:50 Re: extension_control_path: ignore empty elements and deduplicate directories