Skip to content

[Caching] Make ActionCache update failure non-fatal temporarily #79931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Changes from all commits
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
26 changes: 24 additions & 2 deletions lib/Frontend/CASOutputBackends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,30 @@ Error SwiftCASOutputBackend::Implementation::finalizeCacheKeysFor(
<< CAS.getID(*CacheKey).toString() << "\' => \'"
<< CAS.getID(*Result).toString() << "\'\n";);

if (auto E = Cache.put(CAS.getID(*CacheKey), CAS.getID(*Result)))
return E;
if (auto E = Cache.put(CAS.getID(*CacheKey), CAS.getID(*Result))) {
// If `SWIFT_STRICT_CAS_ERRORS` environment is set, do not attempt to
// recover from error.
if (::getenv("SWIFT_STRICT_CAS_ERRORS"))
return E;
// Failed to update the action cache, this can happen when there is a
// non-deterministic output from compiler. Check that the cache entry is
// not missing, if so, then assume this is a cache poisoning that might
// be benign and the build might continue without problem.
auto Check = Cache.get(CAS.getID(*CacheKey));
if (!Check) {
// A real CAS error, return the original error.
consumeError(Check.takeError());
return E;
}
if (!*Check)
return E;
// Emit an error message to stderr but don't fail the job. Ideally this
// should be sent to a DiagnosticEngine but CASBackend lives longer than
// diagnostic engine and needs to capture all diagnostic outputs before
// sending this request.
llvm::errs() << "error: failed to update cache: " << toString(std::move(E))
<< "\n";
}

return Error::success();
}
Expand Down