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

artifact conflict error message can mislead #7658

Closed
benjaminp opened this issue Mar 7, 2019 · 4 comments
Closed

artifact conflict error message can mislead #7658

benjaminp opened this issue Mar 7, 2019 · 4 comments
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged

Comments

@benjaminp
Copy link
Collaborator

$ bazel version
Build label: 0.23.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Mar 4 10:37:56 2019 (1551695876)
Build timestamp: 1551695876
Build timestamp as int: 1551695876
$ touch WORKSPACE
$ cat > BUILD
load(":rule.bzl", "myrule")

myrule(name = "r1")
myrule(name = "r2")
$ cat > rule.bzl
def _myrule(ctx):
    ctx.actions.write(
        output = ctx.actions.declare_file("out"),
        content = ctx.label.name,
    )

myrule = rule(
    implementation = _myrule,
)
$ bazel build //:*
ERROR: file 'out' is generated by these conflicting actions:
Label: //:r2, //:r1
RuleClass: myrule rule
Configuration: 95bb1aedea26948ffe58c23d29c70794
Mnemonic: FileWrite
Action key: 87b132fee9c1596d980921c810d548a6, eecaf26d6f97724d5ccb4304c6052d09
Progress message: Writing file out
PrimaryInput: (null)
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-fastbuild/bin]out
Primary outputs are different: 400726694, 1792020840
Owner information: //:r2 BuildConfigurationValue.Key[95bb1aedea26948ffe58c23d29c70794] false, //:r1 BuildConfigurationValue.Key[95bb1aedea26948ffe58c23d29c70794] false
MandatoryInputs: are equal
Outputs: Attempted action contains artifacts not in previous action (first 5): 
	out
Previous action contains artifacts not in attempted action (first 5): 
	out
ERROR: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for out, previous action: action 'Writing file out', attempted action: action 'Writing file out'
INFO: Elapsed time: 1.205s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (2 packages loaded, 19 targets configured)

My two actions can't be shared because they have different action keys. That information is in the error message, but the message is also claiming that the two action outputs are different. That information is spurious. (If you set content = '' in rule.bzl, the build will work.) The problem is different notions of artifact equality. Action sharing only requires the exec paths of the output artifacts be identical. The error message, on the other hand, is computed by comparing the output (and input) artifacts using a stronger notion of artifact equality that includes the artifact owner.

See #6272 for another issue related to debugging artifact equality.

@dslomov dslomov added team-Local-Exec Issues and PRs for the Execution (Local) team untriaged bad error messaging Issues where users get stuck because they don't understand what they did wrong type: bug labels Mar 8, 2019
@benjaminp
Copy link
Collaborator Author

It seems this was at least partially addressed by c797411.

@susinmotion susinmotion added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc and removed team-Local-Exec Issues and PRs for the Execution (Local) team labels Sep 17, 2019
@meisterT
Copy link
Member

cc @laszlocsomor

@laszlocsomor
Copy link
Contributor

This is what Bazel 2.0.0 prints:

ERROR: file 'out' is generated by these conflicting actions:
Label: //:r2, //:r1
RuleClass: myrule rule
Configuration: 419a3f9c03a725a237290b10359c9923007948fc3772740ed08cd228e37927c7
Mnemonic: FileWrite
Action key: dd82deb57fdea83d4a86c899b3b4a71479f251c590050b3f497db06886947a5e, 95f8a41213e609480376226d33a30d5ad49b887a60f82c8c58a529029ac4e78f
Progress message: Writing file out
PrimaryInput: (null)
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-fastbuild/bin]out
Owner information: //:r2 BuildConfigurationValue.Key[419a3f9c03a725a237290b10359c9923007948fc3772740ed08cd228e37927c7] false, //:r1 BuildConfigurationValue.Key[419a3f9c03a725a237290b10359c9923007948fc3772740ed08cd228e37927c7] false
MandatoryInputs: are equal
Outputs: are equal
ERROR: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for out, previous action: action 'Writing file out', attempted action: action 'Writing file out'

Is that better? If not, what'd you change?

@benjaminp
Copy link
Collaborator Author

Given that it doesn't falsely claim output are different, the bug is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged
Projects
None yet
Development

No branches or pull requests

5 participants