summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2023-05-16 19:19:36 +0200
committerWilly Tarreau <w@1wt.eu>2023-05-17 09:33:54 +0200
commitc7b9308f20909e4eca2257dd2134f537e89cffec (patch)
tree2f586c9e4554de773c7edf1cf80f972139b94251
parent5345490b8e0a3c82587fd1ccf30244035cf0b1d5 (diff)
downloadhaproxy-c7b9308f20909e4eca2257dd2134f537e89cffec.tar.gz
BUG/MINOR: clock: automatically adjust the internal clock with the boot time
This is a better and more general solution to the problem described in this commit: BUG/MINOR: checks: postpone the startup of health checks by the boot time Now we're updating the now_offset that is used to compute now_ms at the few points where we update the ready date during boot. This ensures that now_ms while being stable during all the boot process will be correct and will start with the boot value right after the boot is finished. As such the patch above is rolled back (we don't want to count the boot time twice). This must not be backported because it relies on the more flexible clock architecture in 2.8.
-rw-r--r--src/check.c3
-rw-r--r--src/haproxy.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/check.c b/src/check.c
index 4e681d5db..a440185da 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1475,7 +1475,6 @@ int start_check_task(struct check *check, int mininter,
int nbcheck, int srvpos)
{
struct task *t;
- ulong boottime = tv_ms_remain(&start_date, &ready_date);
/* task for the check. Process-based checks exclusively run on thread 1. */
if (check->type == PR_O2_EXT_CHK)
@@ -1505,7 +1504,7 @@ int start_check_task(struct check *check, int mininter,
mininter = global.max_spread_checks;
/* check this every ms */
- t->expire = tick_add(now_ms, MS_TO_TICKS(boottime + mininter * srvpos / nbcheck));
+ t->expire = tick_add(now_ms, MS_TO_TICKS(mininter * srvpos / nbcheck));
check->start = now_ns;
task_queue(t);
diff --git a/src/haproxy.c b/src/haproxy.c
index 35aac95a0..0eb78d857 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2251,13 +2251,16 @@ static void init(int argc, char **argv)
* during config checks (e.g. to schedule certain tasks if needed)
*/
clock_update_date(0, 1);
+ clock_adjust_now_offset();
ready_date = date;
+
/* Note: global.nbthread will be initialized as part of this call */
err_code |= check_config_validity();
/* update the ready date to also account for the check time */
clock_update_date(0, 1);
+ clock_adjust_now_offset();
ready_date = date;
for (px = proxies_list; px; px = px->next) {
@@ -3521,6 +3524,7 @@ int main(int argc, char **argv)
/* update the ready date a last time to also account for final setup time */
clock_update_date(0, 1);
+ clock_adjust_now_offset();
ready_date = date;
if (global.mode & (MODE_DAEMON | MODE_MWORKER | MODE_MWORKER_WAIT)) {