From 7359c3907643bb11ab3fccf0e919d0718bb5b545 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 14 Mar 2025 19:18:43 +0100 Subject: [PATCH] libstore: set `connect-timeout` to `5` Right now, Lix waits for quite a while five times[1] if a substituter is down. If the substituter is not reachable for that long, it's probably down or so slow that it doesn't make sense to download from it. Also, most people would abort earlier assuming that Lix just behaves weird in that case. Reducing the timeout to 5s to make the behavior a little better. If people live in areas with poor connection where a higher timeout would be appropriate, I'd argue that they should increase the timeout rather than requiring everbody else to set it to a non-zero value. Additionally, communicate how often we're re-trying. [1] Because of `download-attempts` from `nix.conf(5)` Change-Id: I8500dce0c8230247dd492e43cc7af4d3b58c4710 --- doc/manual/rl-next/connect-timeout-default.md | 10 ++++++++++ lix/libstore/file-transfer-settings/connect-timeout.md | 2 +- lix/libstore/filetransfer.cc | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 doc/manual/rl-next/connect-timeout-default.md diff --git a/doc/manual/rl-next/connect-timeout-default.md b/doc/manual/rl-next/connect-timeout-default.md new file mode 100644 index 000000000..dd471bfa0 --- /dev/null +++ b/doc/manual/rl-next/connect-timeout-default.md @@ -0,0 +1,10 @@ +--- +synopsis: Set default of `connect-timeout` to `5` +issues: [] +cls: [2799] +category: Miscellany +credits: [ma27] +--- + +By default, the connection timeout to substituters is now 5s instead of 300s. +That way, unavailable substituters are detected quicker. diff --git a/lix/libstore/file-transfer-settings/connect-timeout.md b/lix/libstore/file-transfer-settings/connect-timeout.md index b76fc306d..98f8a16d0 100644 --- a/lix/libstore/file-transfer-settings/connect-timeout.md +++ b/lix/libstore/file-transfer-settings/connect-timeout.md @@ -2,7 +2,7 @@ name: connect-timeout internalName: connectTimeout type: unsigned long -default: 0 +default: 5 --- The timeout (in seconds) for establishing connections in the binary cache substituter. It corresponds to `curl`’s diff --git a/lix/libstore/filetransfer.cc b/lix/libstore/filetransfer.cc index 01d0a0580..f94691974 100644 --- a/lix/libstore/filetransfer.cc +++ b/lix/libstore/filetransfer.cc @@ -889,9 +889,9 @@ struct curlFileTransfer : public FileTransfer std::uniform_real_distribution<> dist(0.0, 0.5); int ms = parent.baseRetryTimeMs * std::pow(2.0f, attempt - 1 + dist(random)); if (totalReceived) { - warn("%s; retrying from offset %d in %d ms", context, totalReceived, ms); + warn("%s; retrying from offset %d in %d ms (attempt %d/%d)", context, totalReceived, ms, attempt, tries); } else { - warn("%s; retrying in %d ms", context, ms); + warn("%s; retrying in %d ms (attempt %d/%d)", context, ms, attempt, tries); } std::this_thread::sleep_for(std::chrono::milliseconds(ms));