summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-worker.cc5
-rw-r--r--doc/examples/configure-index5
-rwxr-xr-xtest/integration/test-bug-869859-retry-downloads13
3 files changed, 20 insertions, 3 deletions
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 7be51d114..1bf07e82a 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -644,7 +644,10 @@ void pkgAcquire::Worker::HandleFailure(std::vector<pkgAcquire::Item *> const &It
if (_config->FindB("Acquire::Retries::Delay", true))
{
auto Iter = _config->FindI("Acquire::Retries", 3) - Owner->Retries - 1;
- auto Dur = std::chrono::seconds(1 << Iter);
+ auto const MaxDur = _config->FindI("Acquire::Retries::Delay::Maximum", 30);
+ auto Dur = std::chrono::seconds(std::min(1 << Iter, MaxDur));
+ if (_config->FindB("Debug::Acquire::Retries"))
+ std::clog << "Delaying " << SavedDesc.Description << " by " << Dur.count() << " seconds" << std::endl;
Owner->FetchAfter(currentTime + Dur);
}
else
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index e74ebc3d7..4eca100f5 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -231,7 +231,9 @@ Acquire
{
Queue-Mode "<STRING>"; // host or access
Retries "<INT>" {
- Delay "<BOOL>"; // whether to backoff between retries using the delay: method
+ Delay "<BOOL>" { // whether to backoff between retries using the delay: method
+ Maximum "<INT>"; // maximum number of seconds to delay an item per retry
+ };
};
Source-Symlinks "<BOOL>";
ForceHash "<STRING>"; // hashmethod used for expected hash: sha256, sha1 or md5sum
@@ -557,6 +559,7 @@ Debug
Acquire::cdrom "<BOOL>"; // Show cdrom debug output
Acquire::Transaction "<BOOL>";
Acquire::Progress "<BOOL>";
+ Acquire::Retries "<BOOL>"; // Debugging for retries, especially delays
aptcdrom "<BOOL>"; // Show found package files
IdentCdrom "<BOOL>";
acquire::netrc "<BOOL>"; // netrc parser
diff --git a/test/integration/test-bug-869859-retry-downloads b/test/integration/test-bug-869859-retry-downloads
index 86203f794..66e158a9d 100755
--- a/test/integration/test-bug-869859-retry-downloads
+++ b/test/integration/test-bug-869859-retry-downloads
@@ -21,7 +21,18 @@ rm -f testpkg_1_all.deb
msgmsg 'Fail after too many retries'
webserverconfig 'aptwebserver::failrequest' '429'
webserverconfig 'aptwebserver::failrequest::pool/testpkg_1_all.deb' '99'
-testfailure apt download testpkg -o acquire::retries=3
+testfailureequal "Delaying http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 by 1 seconds
+Ign:1 http://localhost:${APTHTTPPORT} stable/main all testpkg all 1
+ 429 Unknown HTTP code
+Delaying http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 by 2 seconds
+Ign:1 http://localhost:${APTHTTPPORT} stable/main all testpkg all 1
+ 429 Unknown HTTP code
+Delaying http://localhost:${APTHTTPPORT} stable/main all testpkg all 1 by 4 seconds
+Ign:1 http://localhost:${APTHTTPPORT} stable/main all testpkg all 1
+ 429 Unknown HTTP code
+Err:1 http://localhost:${APTHTTPPORT} stable/main all testpkg all 1
+ 429 Unknown HTTP code
+E: Failed to fetch http://localhost:${APTHTTPPORT}/pool/testpkg_1_all.deb 429 Unknown HTTP code" apt download testpkg -o acquire::retries=3 -o debug::acquire::retries=true -q
testfailure test -f testpkg_1_all.deb
msgmsg 'Success in the third try'