Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/libstore/filetransfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,9 @@ struct curlFileTransfer : public FileTransfer
// Most 4xx errors are client errors and are probably not worth retrying:
// * 408 means the server timed out waiting for us, so we try again
err = Misc;
} else if (httpStatus == 501 || httpStatus == 505 || httpStatus == 511) {
// Let's treat most 5xx (server) errors as transient, except for a handful:
// * 501 not implemented
// * 505 http version not supported
// * 511 we're behind a captive portal
} else if (httpStatus >= 500 && httpStatus <= 599) {
// a server is unlikely to 5xx unless there is a critical configuration/system error
// we can't recover from an error that isn't our fault so give up
err = Misc;
} else {
// Don't bother retrying on certain cURL errors either
Expand Down
14 changes: 12 additions & 2 deletions src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class HttpBinaryCacheStore : public virtual BinaryCacheStore
void maybeDisable()
{
auto state(_state.lock());
if (state->enabled && settings.tryFallback) {
if (state->enabled) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can PR this PR regardless, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, what does this mean?

int t = 60;
printError("disabling binary cache '%s' for %s seconds", config->getHumanReadableURI(), t);
state->enabled = false;
Expand Down Expand Up @@ -196,8 +196,14 @@ class HttpBinaryCacheStore : public virtual BinaryCacheStore
try {
(*callbackPtr)(std::move(result.get().data));
} catch (FileTransferError & e) {
if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden)
if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden) {
return (*callbackPtr)({});
}
// if the server is having errors then give up on it
if (e.error == FileTransfer::Misc) {
maybeDisable();
return (*callbackPtr)({});
}
maybeDisable();
callbackPtr->rethrow();
} catch (...) {
Expand All @@ -219,6 +225,10 @@ class HttpBinaryCacheStore : public virtual BinaryCacheStore
} catch (FileTransferError & e) {
if (e.error == FileTransfer::NotFound)
return std::nullopt;
if (e.error == FileTransfer::Misc) {
maybeDisable();
return std::nullopt;
}
maybeDisable();
throw;
Comment thread
jadewilk marked this conversation as resolved.
Outdated
}
Expand Down
Loading