-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[MNG-8736] Fix concurrency issue in model building with profile activation #2378
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@wendigo can you verify this fix? |
|
@cstamas i did. Doesn't work |
I'm still getting wrong model from time to time |
|
|
It also fails during execution: |
This commit addresses multiple critical issues in the profile activation context recording and caching mechanism during model inheritance: ## Issues Fixed: 1. **Profile Activation Context Recording Bug**: When there was a cache hit in readAsParentModel(), the keys accessed during cache matching re-evaluation were lost because the recording context was discarded without merging the recorded keys into the parent context. 2. **Recording Context Isolation**: Parent model processing was polluting the child's recording context with intermediate keys that weren't essential to the final result, leading to noisy cache keys and reduced cache effectiveness. 3. **Profile Injection Precedence**: Profile properties from distant ancestors were incorrectly overriding direct properties from closer ancestors due to improper profile injection timing during inheritance assembly. ## Solutions Implemented: 1. **Cache Hit Recording Fix**: - Create a separate recording context for cache matching re-evaluation - Replay cached record keys into the parent recording context on cache hits - Ensure all essential keys are captured regardless of cache hit/miss 2. **Recording Context Isolation**: - Use separate recording contexts for parent model processing - Only replay essential keys from the final result into parent context - Maintain clean, precise cache keys for better performance 3. **Profile Injection Timing**: - Inject profiles into child models using parent's profile list - Ensure proper precedence where child elements override parent elements - Maintain correct inheritance hierarchy during profile activation ## Technical Details: - Made DefaultProfileActivationContext.Record fields package-private for merging - Added replayRecordIntoContext() method for proper key propagation - Updated profile injection to respect inheritance precedence rules - Enhanced MavenModelMerger to handle profile content merging correctly ## Benefits: - Eliminates race conditions in concurrent model building scenarios - Improves cache effectiveness through cleaner, more precise cache keys - Ensures correct profile activation context propagation through inheritance - Maintains proper property precedence in complex inheritance hierarchies - Reduces memory usage by avoiding over-recording of intermediate keys This fix ensures that profile activation behaves consistently and correctly in both single-threaded and multi-threaded environments, while maintaining optimal performance through improved caching mechanisms.
Contributor
Author
This looks like a different issue. Can you confirm this PR fixes the wrong computation of effective models ? |
|
@gnodet it does. I'm going to report a separate issue for the execution. |
cstamas
approved these changes
Jun 6, 2025
|
Resolve #9563 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues Fixed:
Profile Activation Context Recording Bug: When there was a cache hit
in readAsParentModel(), the keys accessed during cache matching re-evaluation
were lost because the recording context was discarded without merging the
recorded keys into the parent context.
Recording Context Isolation: Parent model processing was polluting the
child's recording context with intermediate keys that weren't essential to
the final result, leading to noisy cache keys and reduced cache effectiveness.
Profile Injection Precedence: Profile properties from distant ancestors
were incorrectly overriding direct properties from closer ancestors due to
improper profile injection timing during inheritance assembly.
Solutions Implemented:
Cache Hit Recording Fix:
Recording Context Isolation:
Profile Injection Timing:
Technical Details:
Benefits:
This fix ensures that profile activation behaves consistently and correctly
in both single-threaded and multi-threaded environments, while maintaining
optimal performance through improved caching mechanisms.
JIRA issue: MNG-8736