From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [BUG]: the walsender does not update its IO statistics until it exits |
Date: | 2025-02-26 09:48:50 |
Message-ID: | Z77jgvhwOu9S0a5r@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Wed, Feb 26, 2025 at 03:37:10PM +0900, Michael Paquier wrote:
> On Tue, Feb 25, 2025 at 01:42:08PM +0000, Bertrand Drouvot wrote:
> > Now we can see that the numbers increased for the relation object and that we
> > get non zeros numbers for the wal object too (which makes fully sense).
> >
> > With the attached patch applied, we would get the same numbers already in
> > step 4. (means the stats are flushed without the need to wait for the walsender
> > to exit).
>
> @@ -2793,6 +2794,12 @@ WalSndLoop(WalSndSendDataCallback send_data)
> if (pq_flush_if_writable() != 0)
> WalSndShutdown();
>
> + /*
> + * Report IO statistics
> + */
> + pgstat_flush_io(false);
> + (void) pgstat_flush_backend(false, PGSTAT_BACKEND_FLUSH_IO);
> +
> /* If nothing remains to be sent right now ... */
> if (WalSndCaughtUp && !pq_is_send_pending())
> {
>
> That's bad, worse for a logical WAL sender, because it means that we
> have no idea what kind of I/O happens in this process until it exits,
> and logical WAL senders could loop forever, since v16 where we've
> begun tracking I/O.
Yeah... And while the example shared up-thread is related to logical walsender,
the same issue exists for a physical walsender.
OTOH, It's also great to see that the new stats that have been added (the WAL
ones) helped to spot the issue.
> A non-forced periodic flush like you are proposing here sounds OK to
> me,
Thanks for looking at it!
> but the position of the flush could be positioned better in the
> loop. If there is a SIGUSR2 (aka got_SIGUSR2 is true), WAL senders
> would shut down,
That's true for a physical walsender but I'm not sure it is for a logical
walsender (due to the "sentPtr == replicatedPtr" check in WalSndDone()).
> so it seems rather pointless to do a flush just
> before exiting the process in WalSndDone(), no? I'd suggest to move
> the flush attempt closer to where we wait for some activity, just
> after WalSndKeepaliveIfNecessary().
Yeah I think that makes sense, done that way in the attached.
Speaking about physical walsender, I moved the test to 001_stream_rep.pl instead
(would also fail without the fix).
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Flush-the-IO-statistics-of-active-walsenders.patch | text/x-diff | 2.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2025-02-26 09:53:12 | Re: Lowering temp_buffers minimum |
Previous Message | Richard Guo | 2025-02-26 09:46:24 | Re: Anti join confusion |