Re: Fix cumulative WAL statistics double-counting from parallel workers

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Lukas Fittl <lukas(at)fittl(dot)com>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Ahmed Gouda <gouda0x(at)gmail(dot)com>, Bernd Reiß <bd_reiss(at)gmx(dot)at>
Subject: Re: Fix cumulative WAL statistics double-counting from parallel workers
Date: 2026-11-03 23:17:58
Message-ID: auprpupEq9N4uPFk@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 03, 2026 at 02:58:31PM -0800, Lukas Fittl wrote:
> I don't think (2) is workable, especially if we want a design that
> also works for pgBufferUsage - doing any extra work in InstrStopNode
> is too expensive (instruction-wise, and because of the size of the
> memory being accessed).

Hmm. I have not looked at that. But would it really matter if we
just drop pgWalUsage? We only need the aggregated data from the
leaders and its workers when we are ready to report the data.

> I think (3) could potentially be an alternate, but I don't know if its
> worth the trouble just to avoid the WalUsageAccumDiff on flush, which
> is not in the hot path.

With only HEAD in mind, (2) just seems like the simplest alternative,
because there is less to consider about all these states except
summing them up, where necessary. The origin of the double-counting
comes from the point of pgWalUsage being rather confusing in itself,
because we do not define when it is okay or when is is not okay to
use. If it's confusing, I would not be sad to see it gone on HEAD,
replaced by a WalUsage that just tracks the activity within the
process, combined with a secondary WalUsage where we aggregate from
activity from the workers.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message surya poondla 2026-11-03 23:37:43 Re: Reject access to unlogged tables in contrib modules
Previous Message Michael Paquier 2026-11-03 23:07:33 Re: [PATCH] pgstat: Add helper to drop entries from a stats kind's hash