Question regarding "Make archiver process an auxiliary process. commit" - Mailing list pgsql-hackers

From Sravan Kumar
Subject Question regarding "Make archiver process an auxiliary process. commit"
Date
Msg-id CA+=NbjjqYE9-Lnw7H7DAiS5jebmoMikwZQb_sBP7kgBCn9q6Hg@mail.gmail.com
Whole thread Raw
Responses Re: Question regarding "Make archiver process an auxiliary process. commit"  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
Hi,

I see that in the archiver code, in the function pgarch_MainLoop,
the archiver sleeps for a certain time or until there's a signal. The time
it sleeps for is represented by:

timeout = PGARCH_AUTOWAKE_INTERVAL - (curtime - last_copy_time);
It so happens that last_copy_time and curtime are always set at the same
time which always makes timeout equal (actually roughly equal) to
PGARCH_AUTOWAKE_INTERVAL.

I see that this behaviour was introduced as a part of the commit:
d75288fb27b8fe0a926aaab7d75816f091ecdc27. The discussion thread is:

The change was introduced in v31, with the following comment in the
discussion thread:

- pgarch_MainLoop start the loop with wakened = true when both
notified or timed out. Otherwise time_to_stop is set and exits from
the loop immediately. So the variable wakened is actually
useless. Removed it.

This behaviour was different before the commit: d75288fb27b8fe0a926aaab7d75816f091ecdc27,
in which the archiver keeps track of how much time has elapsed since last_copy_time
in case there was a signal, and it results in a smaller subsequent value of
timeout, until timeout is zero. This also avoids calling pgarch_ArchiverCopyLoop
before PGARCH_AUTOWAKE_INTERVAL in case there's an intermittent signal.

With the current changes it may be okay to always sleep for PGARCH_AUTOWAKE_INTERVAL,
but that means curtime and last_copy_time are no more needed.

I would like to validate if my understanding is correct, and which of the
behaviours we would like to retain.


Thanks & Regards,
Sravan Velagandula
The Enterprise PostgreSQL Company

pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: Failed Assert while pgstat_unlink_relation
Next
From: Michael Paquier
Date:
Subject: Re: Add LZ4 compression in pg_dump