Skip to content
Snippets Groups Projects
Commit 95950429 authored by David Vasek's avatar David Vasek
Browse files

refresh: use exponential retry backoff with base 2 rather than 3

By using the cumulative time since the zone expiration (instead of the last
time interval) we achieve an approximation of exponential retry backoff with
base 2 (rather than with base 3, as it was until now). Now, with every retry attempt,
the interval between refreshes only doubles (with up to 30 second jitter).

This change helps avoid excessive waiting for a refresh when a few early attempts
fail.
parent d19a8509
Branches
Tags
1 merge request!1411refresh: use exponential retry backoff with base 2 rather than 3
/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -139,14 +139,13 @@ static time_t bootstrap_next(const zone_timers_t *timers)
{
time_t expired_at = timers->last_refresh + timers->soa_expire;
// previous interval
// Time since the zone expiration.
// The new interval is double of the previous one (an exponential backoff).
time_t interval = timers->next_refresh - expired_at;
if (interval < 0) {
interval = 0;
}
// exponential backoff
interval *= 2;
if (interval > BOOTSTRAP_MAXTIME) {
interval = BOOTSTRAP_MAXTIME;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment