Skip to content

Commit 6eb4783

Browse files
[Caching] Make ActionCache update failure non-fatal temporarily
Temporarily make action cache update non-fatal and not failing the job. The action cache update failure can happen due to cache poisoning from non-deterministic compiler output. Assume the errors from the non-determinism is benign and can be ignored till all issues are resolved. rdar://146780363
1 parent c0a4056 commit 6eb4783

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/Frontend/CASOutputBackends.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,26 @@ Error SwiftCASOutputBackend::Implementation::finalizeCacheKeysFor(
325325
<< CAS.getID(*CacheKey).toString() << "\' => \'"
326326
<< CAS.getID(*Result).toString() << "\'\n";);
327327

328-
if (auto E = Cache.put(CAS.getID(*CacheKey), CAS.getID(*Result)))
329-
return E;
328+
if (auto E = Cache.put(CAS.getID(*CacheKey), CAS.getID(*Result))) {
329+
// Failed to update the action cache, this can happen when there is a
330+
// non-deterministic output from compiler. Check that the cache entry is
331+
// not missing, if so, then assume this is a cache poisoning that might
332+
// be benign and the build might continue without problem.
333+
auto Check = Cache.get(CAS.getID(*CacheKey));
334+
if (!Check) {
335+
// A real CAS error, return the original error.
336+
consumeError(Check.takeError());
337+
return E;
338+
}
339+
if (!*Check)
340+
return E;
341+
// Emit an error message to stderr but don't failed to job. Ideally this
342+
// should be send to a DiagnosticEngine but CASBackend lives longer than
343+
// diagnostic engine and needs to capture all diagnostic outputs before
344+
// sending this request.
345+
llvm::errs() << "error: failed to update cache: " << toString(std::move(E))
346+
<< "\n";
347+
}
330348

331349
return Error::success();
332350
}

0 commit comments

Comments
 (0)