Skip to content
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

no-cache tag does not apply to the persistent action cache #15516

Open
jgertm opened this issue May 18, 2022 · 8 comments
Open

no-cache tag does not apply to the persistent action cache #15516

jgertm opened this issue May 18, 2022 · 8 comments
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Performance Issues for Performance teams type: bug

Comments

@jgertm
Copy link

jgertm commented May 18, 2022

Description of the bug:

According to https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes, adding the no-cache tag should "[result] in the action or test never being cached (remotely or locally)". This is false, at least using a toolchain that I have written.

I was able to work-around this issue by instead setting the external tag.

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

$ bazel query --output build 'kind("snyk_.* rule", //$SOME_PACKAGE/...)'
# $SOME_PATH/BUILD.bazel:5:16
snyk_scan_test(
  name = "scan_vulnerabilities",
  tags = ["no-cache", "requires-network"],    # notice how it's tagged to NOT CACHE
  generator_name = "$SOME_TARGET",
  generator_function = "clojure_service",
  generator_location = "$SOME_PATH/BUILD.bazel:5:16",
  artifact = "//$SOME_PACKAGE:pom_xml",
  policy = "//:.snyk_prod",
)
...
Loading: 0 packages loaded

$ bazel test //$SOME_PACKAGE:scan_vulnerabilities
...

$ bazel test //$SOME_PACKAGE:scan_vulnerabilities
INFO: Analyzed target //$SOME_PACKAGE:scan_vulnerabilities (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //$SOME_PACKAGE:scan_vulnerabilities up-to-date:
  bazel-bin/$SOME_PATH/scan_vulnerabilities
INFO: Elapsed time: 0.187s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
//$SOME_PACKAGE:scan_vulnerabilities                      (cached) PASSED in 3.5s.   # notice how it's served from cache

Executed 0 out of 1 test: 1 test passes.
INFO: Build completed successfully, 1 total action

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 6.0.0-pre.20220216.3

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 ?

private repo

Have you found anything relevant by searching the web?

No response

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

No response

@brentleyjones
Copy link
Contributor

@bazelbuild/remote-execution

@sgowroji sgowroji added team-Remote-Exec Issues and PRs for the Execution (Remote) team untriaged type: bug labels May 18, 2022
@tjgq
Copy link
Contributor

tjgq commented May 18, 2022

Here's a smaller repro with a trivial test rule:

$ cat WORKSPACE
$ cat BUILD
load(":defs.bzl", "my_test")

my_test(
  name = "my_test",
  tags = ["no-cache"],
)
$ cat defs.bzl
def _impl(ctx):
  script = ctx.actions.declare_file(ctx.label.name)
  ctx.actions.write(script, "exit 0", is_executable = True)

  return DefaultInfo(
    executable = script,
  )

my_test = rule(
  implementation = _impl,
  test = True,
)
$ bazel test :my_test
INFO: Analyzed target //:my_test (47 packages loaded, 377 targets configured).
INFO: Found 1 test target...
Target //:my_test up-to-date:
  bazel-bin/my_test
INFO: Elapsed time: 1.014s, Critical Path: 0.17s
INFO: 5 processes: 3 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 5 total actions
//:my_test                                                               PASSED in 0.1s

Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 5 total actions
$ bazel test :my_test
INFO: Analyzed target //:my_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:my_test up-to-date:
  bazel-bin/my_test
INFO: Elapsed time: 0.182s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
//:my_test                                                      (cached) PASSED in 0.1s

Executed 0 out of 1 test: 1 test passes.
INFO: Build completed successfully, 1 total action

Confirmed with a Bazel built at HEAD. Note that is isn't remote execution related; a local build exhibits the issue.

@brentleyjones
Copy link
Contributor

Note that is isn't remote execution related; a local build exhibits the issue.

FYI, the @bazelbuild/remote-execution team also covers any caching.

@pcjanzen
Copy link
Contributor

Does adding --experimental_allow_tags_propagation help?

#8830

@meisterT
Copy link
Member

When running Tiago's example with --disk_cache but also --nouse_action_cache it is not cached. So it seems we're not respecting the tag for the local action cache. --experimental_allow_tags_propagation doesn't change anything.

@meisterT meisterT added team-Performance Issues for Performance teams P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed team-Remote-Exec Issues and PRs for the Execution (Remote) team untriaged labels Jul 14, 2022
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Sep 18, 2023
@coeuvre coeuvre added not stale Issues or PRs that are inactive but not considered stale and removed stale Issues or PRs that are stale (no activity for 30 days) labels Sep 18, 2023
@carolosf
Copy link

carolosf commented Oct 11, 2023

Still seeing this in Bazel 6.3.2. Used "external" tag as a work-around.

@tjgq tjgq changed the title Test results cached despite no-cache tag no-cache tag does not apply to the persistent action cache Dec 6, 2023
@tjgq
Copy link
Contributor

tjgq commented Dec 6, 2023

Copying from #19909 for the benefit of future readers dealing with cache-busting issues:

There are three caches involved:

  • Skyframe, which is purely in-memory (i.e., it does not survive a shutdown nor a bazel clean)
  • The persistent action cache (serialized to disk but private to the Bazel workspace, can survive a shutdown, gets cleared by a bazel clean)
  • The disk and/or remote cache (external, can be shared by multiple Bazel workspaces, never cleaned up by Bazel)

The Skyframe cache will always be hit on incremental builds and there's afaik no way to disable it. The persistent action cache can be disabled by --nouse_action_cache or by doing a bazel clean. The disk and/or remote cache can be disabled by the no-cache tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Performance Issues for Performance teams type: bug
Projects
None yet
Development

No branches or pull requests

8 participants