At Tue, 6 Dec 2022 17:23:50 +0530, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote in
> Thanks. +1 for fixing this.
>
> I would like to quote recent discussions on reducing the useless
> wakeups or increasing the sleep/hibernation times in various processes
> to reduce the power savings [1] [2] [3] [4] [5]. With that in context,
> does the archiver need to wake up every 60 sec at all when its latch
> gets set (PgArchWakeup()) whenever the server switches to a new WAL
> file? What happens if we get rid of PGARCH_AUTOWAKE_INTERVAL and rely
> on its latch being set? If required, we can spread PgArchWakeup() to
> more places, no?
I thought so first, but archiving may be interrupted for various
reasons (disk full I think is the most common one). So, only
intentional wakeups aren't sufficient.
> Before even answering the above questions, I think we need to see if
> there're any cases where a process can miss SetLatch() calls (I don't
> have an answer for that).
I read a recent Thomas' mail that says something like "should we
consider the case latch sets are missed?". It is triggered by SIGURG
or SetEvent(). I'm not sure but I believe the former is now reliable
and the latter was born reliable.
> Or do we want to stick to what the below comment says?
>
> /*
> * There shouldn't be anything for the archiver to do except to wait for a
> * signal ... however, the archiver exists to protect our data, so she
> * wakes up occasionally to allow herself to be proactive.
> */
So I think this is still valid. If we want to eliminate useless
wakeups, archiver needs to remember whether the last iteration was
fully done or not. But it seems to be a race condition is involved.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center