Bazel: Is Disk Cache Safe to Use?

Created on 2 Nov 2020  路  3Comments  路  Source: bazelbuild/bazel

Description of the problem / feature request:

Aloha!

Our team is considering enabling --disk_cache for developers via .bazelrc. While we were reading the documentation, we saw this:

Since Bazel does not garbage-collect the directory, you might want to automate a periodic cleanup of this directory.
  • Is this a recommendation based on simply reducing the size of the on-disk cache, or is there a reliability component to this as well, where we want to periodically clean up the cache to mitigate potential cache corruption?
  • Moreover, can we run into cache corruption issues when --disk_cache is enabled, and a user is attempting to build or test broken code repeatedly?

What operating system are you running Bazel on?

macOS Catalina 10.15.4 (19E287)

What's the output of bazel info release?

>_ bazel info release
release 3.0.0

Have you found anything relevant by searching the web?

We haven't seen anything else related to this on GitHub issues or elsewhere.

team-Remote-Exec support / not a bug (process) untriaged

All 3 comments

Aloha! Quick ping on this!

This is not a feature request or bug report, but we were wondering if someone could help answer the above concerns that we had.

Thanks!

The recommendation is based on simply reducing the size of on-disk cache.

You won't have cache corruption (if you do, that is a bug):

  1. If you cleanup the cache during a build, the build will fallback to execute locally and upload the result if --remote_upload_local_results is enabled (which is enabled by default).
  2. A upload will first be written to a temporary file and be renamed to the destination when it is finished. So if the upload is canceled, the old cache is still there.
  3. If there are multiple Bazel instances uploading the same action result, the last one will override previous ones.

However, this is a known issue that with --remote_download_minimal, the remote cache is expected to not evict outputs during a build. https://github.com/bazelbuild/bazel/issues/8250

Based on your use case, I think --disk_cache is safe to go.

Closing. Feel free to re-open if this is still an issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ob picture ob  路  3Comments

ajaysaini-sgvu picture ajaysaini-sgvu  路  3Comments

alexandrvb picture alexandrvb  路  3Comments

GaofengCheng picture GaofengCheng  路  3Comments

f1recracker picture f1recracker  路  3Comments