From 7b9dea5a7c43fd91bcd23d1585d39a726d098285 Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Fri, 8 Nov 2024 15:04:17 +0100 Subject: http: use Retry-After HTTP header to optimize retries Some mirrors like snapshot.debian.org apply strict http rate limits. While apt already has an exponential backoff mechanism implemented, this is not sufficient due to the following reasons: 1. all retries happen roughly at the same time 2. the retry-after information from the server is not used We fix this by improving the algorithm: First, if present, the timestamp or duration of the Retry-After header is added to the exponential backoff, optimizing for success-on-second-try. Second, a random delay is added (delay += [0, delay]) to distribute the retries to not immediately run into the limit again. To avoid super-long delays, this is capped by the configured maximum delay. This logic only becomes active if the option Acquire::Retries::HandleRetryAfter is enabled. Signed-off-by: Felix Moessbauer --- apt-pkg/acquire-method.h | 1 + 1 file changed, 1 insertion(+) (limited to 'apt-pkg/acquire-method.h') diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index edee93996..387d0984d 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -92,6 +92,7 @@ class APT_PUBLIC pkgAcqMethod // Outgoing messages void Fail(bool Transient = false); + void FailWithContext(std::string Why, bool Transient, std::unordered_map &fields); inline void Fail(const char *Why, bool Transient = false) {Fail(std::string(Why),Transient);}; virtual void Fail(std::string Why, bool Transient = false); virtual void URIStart(FetchResult &Res); -- cgit v1.2.3-70-g09d2