From: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
---|---|
To: | melanieplageman(at)gmail(dot)com |
Cc: | m(dot)melihmutlu(at)gmail(dot)com, robertmhaas(at)gmail(dot)com, andres(at)anarazel(dot)de, masao(dot)fujii(at)oss(dot)nttdata(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_stat_io for the startup process |
Date: | 2023-04-28 02:43:48 |
Message-ID: | 20230428.114348.519597625859326132.horikyota.ntt@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At Fri, 28 Apr 2023 11:15:51 +0900 (JST), Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote in
> At Thu, 27 Apr 2023 17:30:40 -0400, Melanie Plageman <melanieplageman(at)gmail(dot)com> wrote in
> > After a quick example implementation of this, I found that it seemed to
> > try and flush the stats less often on an idle standby (good) than using
> > enable_timeout_every().
>
> Just rearming with the full-interval will work that way. Our existing
> strategy for this is seen in PostgresMain().
>
> stats_timeout = pgstat_report_stat(false);
> if (stats_timeout > 0)
> {
> if (!get_timeout_active(BLAH_TIMEOUT))
> enable_timeout_after(BLAH_TIMEOUT, stats_timeout);
> }
> else
> {
> if (get_timeout_active(BLAH_TIMEOUT))
> disable_timeout(BLAH_TIMEOUT, false);
> }
> WaitLatch();
Im my example, I left out idle-time flushing, but I realized we don't
need the timeout mechanism here since we're already managing it. So
the following should work (assuming the timestamp updates with
GetCurrentTimestamp() in my last patch).
@@ -3889,13 +3900,23 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
/* Update pg_stat_recovery_prefetch before sleeping. */
XLogPrefetcherComputeStats(xlogprefetcher);
+ /*
+ * Report stats; if not time yet, set next WaitLatch to
+ * wake up at the next reporing time.
+ */
+ wait_time = pgstat_report_stat(false);
+
+ /* if no pending stats, sleep forever */
+ if (wait_time == 0)
+ wait_time = -1L;
+
/*
* Wait for more WAL to arrive, when we will be woken
* immediately by the WAL receiver.
*/
(void) WaitLatch(&XLogRecoveryCtl->recoveryWakeupLatch,
WL_LATCH_SET | WL_EXIT_ON_PM_DEATH,
- -1L,
+ wait_time,
WAIT_EVENT_RECOVERY_WAL_STREAM);
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
Attachment | Content-Type | Size |
---|---|---|
v2_pgstat_io_startup.txt | text/plain | 6.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2023-04-28 02:51:22 | Re: Perform streaming logical transactions by background workers and parallel apply |
Previous Message | Kyotaro Horiguchi | 2023-04-28 02:15:51 | Re: pg_stat_io for the startup process |