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

Fix inconsistent resolution ordering #13580

Merged
merged 1 commit into from Jun 25, 2020
Merged

Fix inconsistent resolution ordering #13580

merged 1 commit into from Jun 25, 2020

Conversation

melix
Copy link
Contributor

@melix melix commented Jun 24, 2020

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

Gradle Core Team Checklist

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation
  • Recognize contributor in release notes

@melix melix added this to the 6.6 RC1 milestone Jun 24, 2020
@melix melix requested a review from ljacomet June 24, 2020 16:53
@melix melix self-assigned this Jun 24, 2020
@melix
Copy link
Contributor Author

melix commented Jun 24, 2020

If we do a 6.5.1 this is a serious candidate.

@melix
Copy link
Contributor Author

melix commented Jun 24, 2020

@bot-gradle test this

@bot-gradle
Copy link
Collaborator

OK, I've already triggered ReadyForMerge build for you.

Copy link
Member

@ljacomet ljacomet left a 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.

@melix
Copy link
Contributor Author

melix commented Jun 25, 2020

@ljacomet PTAL
@bot-gradle test RFM

@bot-gradle
Copy link
Collaborator

Sorry some internal error occurs, please contact the administrator @blindpirate

@melix
Copy link
Contributor Author

melix commented Jun 25, 2020

@bot-gradle test RFM

@bot-gradle
Copy link
Collaborator

Sorry some internal error occurs, please contact the administrator @blindpirate

@melix
Copy link
Contributor Author

melix commented Jun 25, 2020

@bot-gradle test this

@bot-gradle
Copy link
Collaborator

Sorry some internal error occurs, please contact the administrator @blindpirate

@melix
Copy link
Contributor Author

melix commented Jun 25, 2020

@bot-gradle test this

@bot-gradle
Copy link
Collaborator

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
Copy link
Member

@ljacomet ljacomet left a 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 😉

@melix melix merged commit a44f559 into master Jun 25, 2020
@wolfs wolfs deleted the cc/dm/issue-13555 branch June 18, 2021 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile classpath configuration is not deterministic
3 participants