Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits
Date
Msg-id Z_NxMhkBl0PlTOl0@paquier.xyz
Whole thread Raw
In response to Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits  (vignesh C <vignesh21@gmail.com>)
Responses Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits
List pgsql-hackers
On Fri, Apr 04, 2025 at 09:33:46PM +0530, vignesh C wrote:
> The new test added currently passes even without the patch. It would
> be ideal to have a test that fails without the patch and passes once
> the patch is applied.

Right.  The subscription test and logical WAL senders passes without
the patch, because we are able to catch some WAL activity through
pgoutput.  The recovery test for physical WAL sender fails without the
patch on timeout.

We could need something more advanced here for the logical case, where
we could use pg_recvlogical started in the background with a hardcoded
endpos, or just kill the pg_recvlogical command once we have checked
the state of the stats.  I am not sure if this is worth the cycles
spent on, TBH, so I would be happy with just the physical case checked
in TAP as it's simpler because streaming replication makes that easy
to work with.

One thing that I'm a bit unhappy about in the patch is the choice to
do the stats updates in WalSndLoop() for the logical WAL sender case,
because this forces an extra GetCurrentTimestamp() call for each loop,
and that's never a cheap system call in what can be a hot code path.
How about doing the calculations in WalSndWaitForWal() for the logical
part, relying on the existing GetCurrentTimestamp() done there?
That's also where the waits are handled for the logical part, so there
may be a good point in keeping this code more symmetric for now,
rather than split it.

Saying that, here is a version 7 with all that included, which is
simpler to read.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Unquoted file name in an error message
Next
From: Michael Paquier
Date:
Subject: Re: Correct mismatched verb in a message