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

From: Lukas Fittl <lukas(at)fittl(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
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-04 07:49:03
Message-ID: CAP53PkzVj_77UeTHBqPBz2i_R=xjqfqP+bQq7eFLjOyj7tpV3Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 3, 2026 at 11:32 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Tue, Nov 03, 2026 at 04:56:43PM -0800, Lukas Fittl wrote:
> > The only way to avoid extra work in InstrStopNode is to have a global
> > that represents what pgWalUsage currently is (leader + worker), but
> > maybe I'm missing something in your argument?
>
> Speaking HEAD-only here, I still think that accumulating the worker
> numbers in pgWalUsage is an abuse of the facility. I'm finding this
> point to be what itches me the most regarding this thread.

+1 on that, I'd love to find a way to avoid that.

I think ultimately our problem is that we need some way to "attach"
the worker WAL/buffer activity to the right executor node (i.e. the
one that caused a nested statement to be called that had worker
activity), and that node then needs to be able to accumulate that
activity upwards to parent nodes, potentially other parent statements,
and the query-level instrumentation, all without affecting the global
top value like it does today.

There is some overlap here with the stack-based instrumentation work
(which has a more explicit accumulation pass to propagate information
upwards on query end, vs relying on the nested nature of
InstrStopNode), and with that in place we might be able to devise a
design where we just remember the extra instrumentation on the current
stack entry, and then can keep it separated, avoiding mixing it up
with the leader-only global. If helpful I can prototype that to
illustrate it.

That said, I'm still leaning towards going with one of the "simpler"
approaches I sketched out, FWIW, just because it seems less ambitious
in terms of overall code change.

Thanks,
Lukas

--
Lukas Fittl

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou 2026-11-04 08:05:23 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Michael Paquier 2026-11-04 07:32:10 Re: Fix cumulative WAL statistics double-counting from parallel workers