Re: Flush some statistics within running transactions - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Flush some statistics within running transactions
Date
Msg-id aXnveIxQEB5wwcB8@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Flush some statistics within running transactions  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Flush some statistics within running transactions
List pgsql-hackers
Hi,

On Wed, Jan 28, 2026 at 03:35:21PM +0900, Michael Paquier wrote:
> On Mon, Jan 26, 2026 at 06:59:28AM +0000, Bertrand Drouvot wrote:
> > The attached, to apply on top of 0001, fix the issue. However it handles only the
> > WaitLatch in ProcSleep() case and I start to have concern about the others WaitLatch()
> > that would/could be "woken up" every 1s.
> 
> > Using disable_timeout() and enable_timeout_after() in WaitEventSetWait() does not
> > look like a great answer to this concern, so I wonder if we should use a larger
> > flush frequency instead (as proposed up-thread), thoughts? 
> 
> Only a larger frequency is not the correct answer here.  It would just
> reduce the frequency of the extra lock wait messages for one: these
> should never appear more than necessary.

Right. The fix in fix_ProcSleep.txt shared up-thread solves that and has been
added in 0001 attached.

Also the attached is now split in 4 sub-patches with 0002 introducing a new
GUC to control the flush interval (default is 10s). Note that 0001 to 0003 could
be merged as one patch but I did it that way to ease the review.

The new version also adds more documentation and takes care of Sami's comments
shared up-thread.

> And how about for example extension code?

I think that depending on how they write their code around WaitLatch (if any) they
could see messages being reported (if they do) in the logs at stats_flush_interval
frequency.

That said the default value is 10s and that looks pretty long for a latch to wait on.
In any case, they should already take care of a latch being woken by WL_LATCH_SET.

What do you think?

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: pg_stat_io_histogram
Next
From: Amit Kapila
Date:
Subject: Re: pgsql: Prevent invalidation of newly synced replication slots.