-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][meta] Stop election operations when LeaderElectionImpl gets closed #23995
base: master
Are you sure you want to change the base?
Conversation
2d4c72e
to
a62e10a
Compare
@@ -113,6 +116,11 @@ private synchronized CompletableFuture<LeaderElectionState> elect() { | |||
return tryToBecomeLeader(); | |||
} | |||
}).thenCompose(leaderElectionState -> { | |||
synchronized (this) { | |||
if (internalState == InternalState.Closed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add volatile
on internalState
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already covered with synchronized (this)
. this
points to LeaderElectionImpl
instance here.
Fixing a potentially flaky test that uses a bad way to trigger leader election. |
Motivation
In some tests, I noticed that LeaderElectionImpl could continue to make operations and override the closed state.
Modifications
Add checks if the internalState is Closed
Documentation
doc
doc-required
doc-not-needed
doc-complete