Skip to content

Commit

Permalink
remote: properly reset state when using remote cache. Fixes #7555
Browse files Browse the repository at this point in the history
when using --remote_(http)_cache we wouldn't properly reset the state on
the bazel server and so on subsequent command invocations the server
would still think it's using remote caching. this would lead for bazel
to hang indefinitely.

Closes #7562.

PiperOrigin-RevId: 235914044
  • Loading branch information
buchgr authored and laurentlb committed Mar 7, 2019
1 parent e7c770c commit f7d3bae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ private void checkClientServerCompatibility(

@Override
public void afterCommand() {
buildEventArtifactUploaderFactoryDelegate.reset();
actionContextProvider = null;
if (rpcLogFile != null) {
try {
rpcLogFile.close();
Expand All @@ -340,7 +342,6 @@ public void afterCommand() {
rpcLogFile = null;
}
}
buildEventArtifactUploaderFactoryDelegate.reset();
}

@Override
Expand Down
25 changes: 25 additions & 0 deletions src/test/shell/bazel/remote/remote_execution_http_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,29 @@ function test_directory_artifact_in_runfiles_skylark_rest_cache() {
|| fail "Remote cache hit generated different result"
}


function test_remote_state_cleared() {
# Regression test for https://github.com/bazelbuild/bazel/issues/7555
# Test that the remote cache state is properly reset, so that building without
# a remote cache works after previously building with a remote cache.
mkdir -p a
cat > a/BUILD <<'EOF'
genrule(
name = "gen1",
outs = ["out1"],
cmd = "touch $@",
)
EOF

bazel build \
--remote_http_cache=http://localhost:${http_port} \
//a:gen1 \
|| fail "Failed to build //a:gen1 with remote cache"

bazel clean

bazel build //a:gen1 \
|| fail "Failed to build //a:gen1 without remote cache"
}

run_suite "Remote execution and remote cache tests"

0 comments on commit f7d3bae

Please sign in to comment.