-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
repo_mapping
file is generated by conflicting actions
#18666
Comments
cc @sdtwigg |
I added an implementation of You can see that the order of elements in the @lberki Are you aware of any cases in which the order of elements in Although the question remains why there are two separate actions registered in the first place. |
Ouch, this is not great. My guess is that the non-determinism in |
I can confirm that the issue no longer reproduces for me if I enforce deterministic sorting of --- a/src/main/java/com/google/devtools/build/lib/analysis/producers/TransitiveDependencyState.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/producers/TransitiveDependencyState.java
@@ -13,17 +13,27 @@
// limitations under the License.
package com.google.devtools.build.lib.analysis.producers;
+import static java.util.Comparator.comparing;
+
import com.google.devtools.build.lib.analysis.ConfiguredTargetValue;
import com.google.devtools.build.lib.causes.Cause;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.packages.Package;
+import java.util.ArrayList;
+import java.util.Comparator;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
/** Tuple storing state associated with transitive dependencies. */
public final class TransitiveDependencyState {
+ private static final Comparator<Package> PACKAGE_COMPARATOR =
+ comparing(Package::getPackageIdentifier);
+ private static final Comparator<ConfiguredTargetValue> CONFIGURED_TARGET_VALUE_COMPARATOR =
+ comparing((ConfiguredTargetValue value) -> value.getConfiguredTarget().getLabel())
+ .thenComparing(value -> value.getConfiguredTarget().getConfigurationChecksum());
+
private final NestedSetBuilder<Cause> transitiveRootCauses;
/**
@@ -36,6 +46,7 @@ public final class TransitiveDependencyState {
* com.google.devtools.build.lib.skyframe.SkyframeExecutor#shouldStoreTransitivePackagesInLoadingAndAnalysis}.
*/
@Nullable private final NestedSetBuilder<Package> transitivePackages;
+ private final ArrayList<Object> depsToBeSorted = new ArrayList<>();
/**
* Contains packages that were previously computed.
@@ -75,6 +86,21 @@ public final class TransitiveDependencyState {
@Nullable
public NestedSetBuilder<Package> transitivePackages() {
+ if (transitivePackages == null) {
+ return null;
+ }
+ depsToBeSorted.stream()
+ .filter(dep -> dep instanceof Package)
+ .map(dep -> (Package) dep)
+ .sorted(PACKAGE_COMPARATOR)
+ .forEachOrdered(transitivePackages::add);
+ depsToBeSorted.stream()
+ .filter(dep -> dep instanceof ConfiguredTargetValue)
+ .map(dep -> (ConfiguredTargetValue) dep)
+ .sorted(CONFIGURED_TARGET_VALUE_COMPARATOR)
+ .map(ConfiguredTargetValue::getTransitivePackages)
+ .forEachOrdered(transitivePackages::addTransitive);
+ depsToBeSorted.clear();
return transitivePackages;
}
@@ -95,7 +121,7 @@ public final class TransitiveDependencyState {
if (transitivePackages == null) {
return;
}
- transitivePackages.addTransitive(configuredTarget.getTransitivePackages());
+ depsToBeSorted.add(configuredTarget);
}
/**
@@ -107,7 +133,7 @@ public final class TransitiveDependencyState {
if (transitivePackages == null) {
return;
}
- transitivePackages.add(pkg);
+ depsToBeSorted.add(pkg);
}
@Nullable
|
`describedNestedSetFingerprint` appended a `StringBuilder` to itself in a loop instead of the actual item from the nested set, resulting in OOMs in `Runfiles#describeKey` and `RepoMappingManifestAction#describeKey`. Work towards #18666 Closes #18668. PiperOrigin-RevId: 540270874 Change-Id: Id408ab4c2438bea264b586f8ae5567dc41260242
`describedNestedSetFingerprint` appended a `StringBuilder` to itself in a loop instead of the actual item from the nested set, resulting in OOMs in `Runfiles#describeKey` and `RepoMappingManifestAction#describeKey`. Work towards bazelbuild#18666 Closes bazelbuild#18668. PiperOrigin-RevId: 540270874 Change-Id: Id408ab4c2438bea264b586f8ae5567dc41260242
From the perspective of Addressing the non-determinism should let action sharing work again and side-step the trim_test_configuration issue while also being better for build incrementality anyways. |
PiperOrigin-RevId: 541656611 Change-Id: Ie6c365275003343dc2bf0520a305e005ec48550b
@bazel-io flag |
@bazel-io fork 6.3.0 |
Hard to say 100% since it was pretty flaky, but it looks like in 20 runs in my repro case I could never get the failure! Thanks folks! |
@lberki @fmeum FYI, below is the list of the missing files: |
@iancha1992 Looks like we can't cherry-pick this as the affected files don't even exist in 6.3.0. |
Thank you Ian for looking into this. Before we call off the cherry-picks, let's investigate whether it's possible to backport the prerequisite changes. Let's discuss this (and other related cherry-pick PRs) in #18419. |
`describedNestedSetFingerprint` appended a `StringBuilder` to itself in a loop instead of the actual item from the nested set, resulting in OOMs in `Runfiles#describeKey` and `RepoMappingManifestAction#describeKey`. Work towards bazelbuild#18666 Closes bazelbuild#18668. PiperOrigin-RevId: 540270874 Change-Id: Id408ab4c2438bea264b586f8ae5567dc41260242
We're also hitting this issue in android (b/288969037) even after bd9eb4f |
@Colecf is your case fixed or should we re-open this one? |
Sorry, we were able to fix it by adding |
Description of the bug:
This error is produced intermittently in our project. In the failure case the diff of the configurations mentioned in above is:
It seems like passing
--trim_test_configuration=false
works around this issue. I believe this was introduced in 698a514 but it still repros on HEAD today.What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
This can be reproduced on macOS with this project: repro.zip by running
./repro.sh
. It cleans and builds multiple times since the issue is intermittent.Which operating system are you running Bazel on?
macOS
What is the output of
bazel info release
?698a514
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.bazelisk
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.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: