-
Notifications
You must be signed in to change notification settings - Fork 4k
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
genquery + transitions: build error when query succeeds #14169
Comments
Do you know what causes the cycle in the I'll try to dig up a similar issue someone reported recently. Short story is that
|
Note that a "real build" does not suffer the same cyclic dependency:
|
You're right - apologies. I poked around more and I'm stumped. I get the same error with:
This tells me the cycle is getting reported through routine analysis of the deps from If I try building something else, like a Do you have any toy reproduction scenarios not specific to the Go rules? |
I think this toy example replicates:
It exploits the facts that |
Okay, now I remember. This is a known discrepancy between
So the short story is both The most straightforward paths would be one of:
Happy to talk through more the different options. |
Thanks for digging in. I'm not sure how to resolve though:
|
There is a test in Uber to verify that a service doesn't have any transitive dependency on some IDL files. The test uses a I am not sure if there is any workaround. It's probably not a good idea to run either |
Okay. To be clear, the problem is this quirk @linzhp, your test is part of a big |
@haxorz - who has expertise on the core Bazel logic Was there any other best practice recommendation aside from eliminating the cycles or prefering aspects? |
No. The last major time this came up internally at Google, "eliminate the cycle" was viable and was the approach taken. |
We were able to write an aspect and a rule that depend on the aspect to collect transitive dependencies for the test to check. |
Thanks all! |
I would suggest to keep this issue open instead. It helps highlighting the problem where genquery and transition does not play well with each others. The 2 ways we should try to solve this:
|
I support the first item (documentation) and suggest a dedicated issue for it. Since that's something we can more actionably address. For the second, I hear your point. This gets into the philosophy of what it means for issues to be open / closed, prioritized at whatever level, etc. I don't see any scenario where fixing this principally will happen any time soon barring heroic work by an enthusiastic contributor. This is really about redesigning So there's real design work to try to figure out how or if I'm not sure if your "traverse N times" idea is a less complicated adjustment to work around the problem? If so, could you sketch up a prototype to demonstrate the effect? Anyway, I don't know what the right call is re: issue status. I hear your point. But I wouldn't want keeping the issue open to imply a stronger promise to address it than we're making. And we can still access closed issues, of course. How about if I run this past one of our Bazel PMs to get some more thought out perspective on that? |
Thanks for the quick reply @gregestren If re-opening the issue is not ideal, then we can create 2 new issues: 1 for documenting the suggestion and 1 for designing solutions and tradeoffs. We can leave the latter to be low priority until the problem becomes more painful and worth the ROI to solve. Personally I prefer redesigning rules_go's staticanalysis framework to use something like Validation Actions instead. May be if we can refactor rules_go toward that direction, then we can eliminate the need for cycle dependencies in rules_go and downgrade the |
Does anyone have an example aspect they can point to for collecting transitive deps? Maybe @linzhp? |
Something like this: DEPS_ATTRS = [
"deps",
"embed",
"proto",
]
DepsetInfo = provider(
fields = {
"depset": "transitive dependencies",
},
)
def _transitive_deps_aspect_impl(target, ctx):
deps = []
for attr in DEPS_ATTRS:
if hasattr(ctx.rule.attr, attr):
value = getattr(ctx.rule.attr, attr)
if type(value) == "list":
deps.extend([dep[DepsetInfo].depset for dep in value])
else:
deps.append(value[DepsetInfo].depset)
return [DepsetInfo(depset = depset(direct = [(ctx.label, ctx.rule.kind)], transitive = deps))]
transitive_deps_aspect = aspect(
implementation = _transitive_deps_aspect_impl,
provides = [DepsetInfo],
attr_aspects = DEPS_ATTRS,
) |
https://github.com/bazelbuild/rules_license/ is a pretty good example of how to use aspect to collect dependencies information ;) |
Thank you both! This is useful. |
This has come up again in bazelbuild/rules_go#3883, so I will reopen. @gregestren @haxorz Do you see a way to make |
The Google discussion on genquery + cycles happened at b/141613846 and got committed effort in 2022 / 2023. Does fa05a10 help? This was part of that. |
It fixes the problem and returns reasonable results on the reproducer. What's the status of that flag? Are there any known blockers to flipping it? |
It's been enabled in Google for a year. According to b/271868450 it increases One of the bug comments: "strongly suggesting that this regression is limited to builds with many forbidden dependency tests". The author of the fix, @anakanemison, left Google a while ago so we can't expect them to follow up. But they did an awesome job addressing this (thanks again, if you see this!). @justinhorvitz might have thoughts as a stakeholder in memory optimization. The Google flip added this to the common blazerc to help:
Given all this, I suggest we flip this for Bazel. |
I'm familiar with Mark's work to address the Setting the max skyframe drops per invocation was in response to A note on the aspect approach to collect transitive deps - we had an effort to investigate the feasibility of that (b/146629125) but it stalled due to some fundamental differences between aspect propagation and |
Even without better automation for retrying OOMs, I think that the average Bazel user would be better with an OOMing build than one that drags on for hours due to intermediate results getting dropped repeatedly. I would probably flip the Skyframe flags first and independently of the new genquery implementation. @justinhorvitz Given the need to deal with , can I just submit a PR to change the defaults to 10 or do you need to take care of this in some other way? |
@haxorz we need to consider depserver before changing the default values of the flags |
Thanks for thinking of this, Justin. Answer is "sorta". Chat me internally. |
Update: we've begun the process of passing the current default values as flags where needed and need to wait for that to propagate to all environments. I will update once it's safe to proceed with changing the defaults. |
@fmeum at last the changes have propagated universally so it is now safe to proceed with changing the default flag values. |
Thanks, I sent #22597. |
It seems like WORKSPACE
BUILD
|
@erichiggins0 Could you check whether this PR fixed the issue? #22892 |
hmm @fmeum I'm happy to check but tbh I'm not sure how to do it 😅 Could you help me out a bit? Alternatively, the files I shared above should reproduce the issue - the only thing I didn't include is |
@erichiggins0 Sorry for the delay, I was OOO. I verified that the issue isn't present in |
) This is not a cherry-pick, but a dedicated fix for Bazel 7.x. Bazel 8 is not affected as the switch to the Starlarkified exec configuration has already resolved this problem. Fixes #14169
A fix for this issue has been included in Bazel 7.3.0 RC1. Please test out the release candidate and report any issues as soon as possible. |
Description of the problem / feature request:
Using Bazel 4.2.0, a
genquery
expression fails when the correspondingbazel query
succeeds, apparently due to not handling an important transition used by rules_go to implement the "nogo" static analysis tool.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
To reproduce:
The error message:
This was discovered after rules_go moved to transitions for static analysis support in this commit:
bazelbuild/rules_go@63dfd99
I don't see any way to fix it within rules_go.
What operating system are you running Bazel on?
MacOS Catalina
What's the output of
bazel info release
?release 4.2.0
Have you found anything relevant by searching the web?
I found no relevant results for the terms: genquery transitions
The text was updated successfully, but these errors were encountered: