Repository navigation
5.x backport of #4952: stop the database control listener without waiting out its poll delay - #4954
Merged
Conversation
DatabaseControlListener slept between polls with Task.Delay and no cancellation token, and StopAsync awaits the polling loop. Once the control queue has been quiet for ten seconds that sleep is five seconds, so stopping a quiet node could wait up to five seconds before endpoint draining, ownership release and node deregistration ran. CosmosDbControlListener had the same shape with a one second delay. Both loops now pass the listener's cancellation token to the startup stagger and to the delay between polls, treat cancellation as a normal stop, and StopAsync tolerates a loop that ended cancelled. This matches what OracleControlListener already does.
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.
Backport of #4952 (me-azlam-kp) to the
5.0branch, cherry-picked from f9f7424 with the author's commit kept.On 5.x the control listener's delay between polls is a fixed one second rather than 6.x's idle backoff, so the worst case was about one second instead of five, but the defect is the same: neither
Task.DelayinDatabaseControlListenerobserved the listener's cancellation whileStopAsyncawaited the loop, so stopping a node waited out whatever was left of the sleep before endpoint draining, ownership release and node deregistration could run.CosmosDbControlListenerhad the same shape and gets the same change.What differs from the 6.x commit
Task.Delay(1.Seconds()); there is no idle interval to pass through.StopAsyncand asserts it returns in under 250 ms. Verified red-then-green against this branch: with the pre-fix listener swapped back in it fails on the full second, with the fix it passes.TestContext.Currentis xUnit v3 and 5.x is on v2, so the wait uses a plain timeout.Verified:
PersistenceTestsdatabase_control_listener_shutdownon net9.0;dotnet build wolverine.slnx -c Release -f net9.0clean on this branch.🤖 Generated with Claude Code