bazel: `bazel build //X:all` records target completion events in the BEP stream with `file://` URIs, but sometimes doesn't write files to disk

Description of the bug:

We use --build_event_json_file to watch for target completion events and run some post-processing on the produced files in tandem with Bazel running. With Bazel 6.3.2, this worked fine, though we did run into #17798, and therefore had to add some polling to wait for the files being written to disk. This polling has a built-in (per-target) timeout of 3 minutes, which we ~never see hit (post-processing generally completes within seconds).

When attempting to upgrade to Bazel 7.0.0, we are seeing this timeout regularly getting hit, despite remote cache hits and an otherwise quiescent system. That is, we are seeing target completion events in the BEP stream, but for a small number of those targets, the relevant files never appear on disk (at least within the 3-minute timeout; bazel build finishes within ~40s, so the machine is not particularly overloaded). There does not seem to be any commonality between the files that are not present between different bazel build runs; a given target might not be downloaded in one run and be downloaded in another. This behavior occurs with both fully-cached and mostly-cached builds.

The same behavior occurs when building with //X:....

We do occasionally see successful builds with Bazel 7, but they are rare (~1%, maybe less). It is possible, of course, that raising the timeout would work, but given that we ~never hit the timeout with Bazel 6 and ~always hit the timeout with Bazel 7, increasing the timeout would represent a significant performance hit.

We have checked the BEP streams between Bazel 6 and Bazel 7 (fully cached build for both) and there are only trivial differences. We took GRPC logs from our remote cache (fully cached build for both) and again there are only trivial differences.

We are using --remote_download_toplevel with both versions. This issue happens with remote caching enabled and remote execution disabled, which is our CI configuration (we know…); we have a separate configuration with remote caching and remote execution enabled that does not appear to exhibit the problem.

We do not see this behavior if we manually expand //X:all on the command line, i.e. listing out all the relevant targets that //X:all would have built.

cc @sushain97 @ngroman @xieyuxi-stripe @coeuvre

Which category does this issue belong to?

No response

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

We haven’t been able to come up with a simple example that reproduces this outside of our codebase.

Which operating system are you running Bazel on?

x86-64 Linux

What is the output of bazel info release?

release 7.0.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Yes, this is a regression. We have not tried to isolate the relevant commit(s).

Have you found anything relevant by searching the web?

I have looked through the last several months of Github issues, but do not see anything relevant.

bazel-discuss does not appear to have anything related.

Any other information, logs, or outputs that you want to share?

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@bazel-io fork 7.1.0

I added this issue as a soft release blocker for 7.0.1, since the fix is still unclear and there is a workaround. We can maybe have a 7.0.2 if this doesn’t get fix in time.

@bazel-io fork 7.0.1

This is a bit of a shot in the dark, but does setting --noexperimental_merged_skyframe_analysis_execution make the issue go away?