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

From: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: 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-10-08 00:26:26
Message-ID: CAN12+Y+_+vehMn8eRPH7Baf5g5JGsSoYJ3be+K=pmtaUVo+szw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

cfbot showed a few Linux failures that were not reliably reproducible. The
failure was an assertion from pgstat_shutdown_hook() calling
pgstat_report_stat() while stats were already being flushed.

I fixed that by making pgstat_shutdown_hook() avoid a recursive flush. The
failure happens when we hit a FATAL while flushing stats. Process exit runs
pgstat_shutdown_hook() before the PG_FINALLY in the original
pgstat_report_stat() call has reset pgStatFlushInProgress.

v16 attached.

--
Sami Imseih
Amazon Web Services (AWS)

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2026-10-08 00:31:55 Re: Comments for lossy ORDER BY are lacking
Previous Message Greg Burd 2026-10-07 22:22:13 Re: Comments for lossy ORDER BY are lacking