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
Fix inconsistent resolution ordering #13580
Conversation
If we do a 6.5.1 this is a serious candidate. |
@bot-gradle test this |
OK, I've already triggered ReadyForMerge build for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see the approach we discussed worked out. A couple comments though, see below.
...t/src/main/java/org/gradle/api/internal/artifacts/dsl/DefaultComponentMetadataProcessor.java
Outdated
Show resolved
Hide resolved
.../java/org/gradle/internal/component/external/model/ivy/RealisedIvyModuleResolveMetadata.java
Show resolved
Hide resolved
...agement/src/main/java/org/gradle/internal/resolve/caching/ComponentMetadataRuleExecutor.java
Show resolved
Hide resolved
...ava/org/gradle/internal/component/external/model/AbstractModuleComponentResolveMetadata.java
Outdated
Show resolved
Hide resolved
@ljacomet PTAL |
Sorry some internal error occurs, please contact the administrator @blindpirate |
@bot-gradle test RFM |
Sorry some internal error occurs, please contact the administrator @blindpirate |
@bot-gradle test this |
Sorry some internal error occurs, please contact the administrator @blindpirate |
@bot-gradle test this |
Sorry some internal error occurs, please contact the administrator @blindpirate |
The fix for #12951 introduced by #12957 worked but made a number of other bugs much more likely to happen: by using the right derivation strategy in each project, we were properly fetching the component metadata we wanted to process from the cache. However, this component metadata was mutable, because of laziness. In particular, derivation of variants require to set the derivation strategy on "deemed immutable" metadata. The problem is that when several configurations are resolved concurrently, we ended up mutating the same component from different threads, with different derivation strategies. The ideal fix would be to have real immutable component metadata from the cache. However, because of laziness (required for performance), we can't do that. The fix in this PR is therefore to create a copy of the module metadata whenever a different derivation strategy needs to be used. It also highlighted another bug, which is that when we use cached component metadata rules, the derivation strategy wasn't part of the cache key, meaning that we would get whatever was first stored in the binary cache. We now properly separate the entries in the cache by amending the cache key with the name of the strategy. This isn't ideal as we could potentially have _stateful_ strategies, but for now there are no such things in the wild. Again in reality we'd like to get rid of the "magic snapshotting" of rules and do something similar to what transforms do, with proper declared input types. Fixes #13555
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and thanks for tests 😉
The fix for #12951 introduced by #12957 worked but made a number
of other bugs much more likely to happen: by using the right derivation
strategy in each project, we were properly fetching the component
metadata we wanted to process from the cache.
However, this component metadata was mutable, because of laziness.
In particular, derivation of variants require to set the derivation
strategy on "deemed immutable" metadata. The problem is that when
several configurations are resolved concurrently, we ended up mutating
the same component from different threads, with different derivation
strategies.
The ideal fix would be to have real immutable component metadata from
the cache. However, because of laziness (required for performance), we
can't do that.
The fix in this PR is therefore to create a copy of the module metadata
whenever a different derivation strategy needs to be used.
It also highlighted another bug, which is that when we use cached
component metadata rules, the derivation strategy wasn't part of the
cache key, meaning that we would get whatever was first stored in the
binary cache.
We now properly separate the entries in the cache by amending the cache
key with the name of the strategy. This isn't ideal as we could potentially
have stateful strategies, but for now there are no such things in the
wild. Again in reality we'd like to get rid of the "magic snapshotting"
of rules and do something similar to what transforms do, with proper
declared input types.
Fixes #13555
Fixes #?
Context
Contributor Checklist
<subproject>/src/integTest
) to verify changes from a user perspective<subproject>/src/test
) to verify logic./gradlew <changed-subproject>:check
Gradle Core Team Checklist