| From: | Sami Imseih <samimseih(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-08-25 01:34:50 |
| Message-ID: | CAA5RZ0towXnuyu-gmUBgo_8J6MXzm=nnduP4f0FmUd49RiFfaA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
> Yeah, that would address my concern and keep memcmp(), so +1.
Thanks. I went ahead and did that in v8-0002 (previously v7-0001).
On top of the txn and non-txn stats split, that patch now moves truncdropped
out of the counter struct and into PgStat_RelationStatus, and adds
StaticAssertDecl
checks so the txn and no-txn counter structs contain only
PgStat_Counter fields with
no padding. That keeps the memcmp() safe and we can avoid doing
field-by-field comparisons. All these changes are kept in one patch as they all
serve the purpose of providing safe memcmp() for the stats.
> If pgstat_prep_database_pending() errors, the shared index (or
> relation) stats have already been updated, while the database stats
> and flushed baseline have not.
>
> I wonder if pgstat_prep_database_pending() should be called before
> the first shared stat update, or if the callback should ensure that
> an error cannot leave the flush partially applied?
That issue is already present in HEAD and is not introduced by this
patch set. pgstat_prep_database_pending() can already ERROR on OOM while
setting up the database pending entry, so this is not new here.
That said, preparing the database pending entry before updating any
stats is probably a better idea just for consistency during such cases,
so I split that out as a standalone fix in v8-0001.
For v8-0003, most of the visible churn comes from splitting out
v8-0001 and v8-0002. Other differences are the custom stats example and
related test updates, plus a few extra padding checks for memcmp() in
flush callbacks. I also removed the pgstat_reset_entry() custom stats
example for now to keep things simple.
--
Sami Imseih
Amazon Web Services (AWS)
| Attachment | Content-Type | Size |
|---|---|---|
| v8-0001-pgstat-Prepare-db-pending-stats-before-flush.patch | application/octet-stream | 2.7 KB |
| v8-0002-pgstat-Split-table-stat-counters-into-transaction.patch | application/octet-stream | 25.8 KB |
| v8-0003-pgstat-Allow-pg_stat_force_next_flush-to-work-in-.patch | application/octet-stream | 97.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Sabino Mullane | 2026-08-25 01:38:58 | Re: [PATCH] Provide support for trailing commas |
| Previous Message | Koshino Taiki | 2026-08-25 01:33:22 | Re: doc: Reformat SELECT queries using GRAPH_TABLE |