| From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Sami Imseih <samimseih(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-31 13:24:06 |
| Message-ID: | apWAdrPhLWzqnwNs@bdtpg |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Sun, Aug 30, 2026 at 09:48:38PM -0500, Sami Imseih wrote:
> Hi,
>
>
> > === 1
> >
> > Thanks! Looking closer, I think there is still another window though:
> >
> > pgstat_unlock_entry() calls LWLockRelease(), which can process a pending
> > interrupt. At that point, the shared relation stats have been updated,
> > while the
> > database pending stats and flushed baseline have not. A later retry could
> > then
> > apply the same delta again.
> >
> > That is also already possible in HEAD and should be very rare in practice.
> > That
> > said, I think it is worth mentioning and deciding whether we want to
> > handle this
> > case too.
> >
>
> I looked at this a bit more. We could close the window you mention
> either by moving pgstat_unlock_entry() until after the pending
> database stats are updated, or by holding interrupts across both the
> shared relation/index update and the pending database update.
>
> But there are still other windows where the relation/index stats and
> database stats can diverge, including a possible double count in the
> database entry, in particular between finishing the relation/index
> flush callbacks and later flushing the database stats.
>
> So I would rather not do anything here for now, including v8-0001,
> and instead take it up in a separate thread. WDYT?
Yeah, given that those windows already exist in HEAD I think it makes sense
to open a dedicated thread.
> > Should we clear this flag between passes, or at least check
> > pgStatFlushInProgress
> > here?
>
>
> Yeah right. I will fix this and send out a new rev.
Thanks!
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jakub Wartak | 2026-08-31 13:25:16 | Re: pg_*_advice: tsv load failure, etc. |
| Previous Message | Henson Choi | 2026-08-31 13:21:42 | Re: Row pattern recognition |