Repository navigation
Conversation
Applying the desired state aspects inside computeIfAbsent failed with "Recursive update" when an aspect looked up the actual resource of the dependent (same key) or of another dependent whose key landed in the same bin. Compute with a lock per dependent instead, and hand the thread already computing a desired state the state as it is so far. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…er configuration Hand the user's bulk dependent, rather than the stand-in the framework creates per resource, to the desired state aspects, and skip the aspects if the context has no controller configuration.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
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
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.
Summary
Fixes in how the desired state aspects are applied, found while reviewing the virtual thread support PR (#3664) and extracted from it.
1. No more
Recursive updatewhen an aspect looks up the actual resourceDefaultContext#getOrComputeDesiredStateForapplied the aspects insideConcurrentHashMap.computeIfAbsent. ADesiredStateAspectthat looks up the actual resource of its dependent asks for the desired state that is being computed, which re-entered the map on the same key. Looking up the actual resource of another dependent could do the same when its key landed in the same bin. Both failed withIllegalStateException: Recursive update.The desired state is now computed outside of the map:
2. Aspects of a bulk dependent receive the dependent the user configured
For a bulk dependent resource the framework creates a stand-in dependent per resource, and that stand-in was handed to the aspects. The aspects now receive the bulk dependent the user configured, through a new
getOrComputeDesiredStateFor(dependentResource, aspectTarget, desiredStateComputer)overload used byBulkDependentResourceReconciler.3. A missing controller configuration is tolerated
The aspects are skipped when the context has no controller configuration, instead of failing with a
NullPointerException, which is the case for contexts created outside of a controller, for example in unit tests.Tests
DesiredStateAspectReentrancyTest: an aspect looking up the actual resource of its own dependent and of another dependent, and the desired state being computed once.DesiredStateAspectAuditTest: the bulk dependent receiving the user's bulk dependent resource, the lookup of the actual resource, and computing the desired state without an aspect configuration.