Fix EventLoopScheduler startup idle tracking race - #136
Open
Dongnyoung wants to merge 3 commits into
Open
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
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 a startup race where
EventLoopSchedulercould start its carrier thread beforeClusterStatewas connected.Before this change, the carrier thread was started inside the
EventLoopSchedulerconstructor. This allowed the carrier loop to reachtryPark()whileclusterState == null, transitioncarrierStatetoPARKED, and skipmarkIdle(id).If
ClusterStatewas connected afterward, the carrier could remain parked while being absent fromIdleCarrierTracker, preventingwakeFirstIdle(...)from discovering it.Changes
EventLoopSchedulerconstructor.startCarrier()for controlled startup.EventLoopSchedulerGrouponly after:ClusterStateis assignedgroupis assignedThis also ensures that the scheduler wiring performed before
Thread.start()is published to the carrier thread through theThread.start()happens-before relationship.Invariant Covered
If a carrier is
PARKEDand connected toClusterState, it must be discoverable throughIdleCarrierTracker/wakeFirstIdle(...).The regression test connects the scheduler to
ClusterStatebefore starting its carrier, waits until the carrier actually parks, and verifies thatwakeFirstIdle(...)can discover it as idle.Testing
git diff --checkLoom Build TestsGitHub Actions workflow passed on the fork.Local Maven execution was not possible because the available local JDK does not provide the Java 28 APIs required by the project.