You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2025/02/17 12:14:17 UTC

[PR] [improve][meta] Stop election operations when LeaderElectionImpl gets closed [pulsar]

lhotari opened a new pull request, #23995:
URL: https://github.com/apache/pulsar/pull/23995

   ### 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
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][meta] Stop election operations when LeaderElectionImpl gets closed [pulsar]

Posted by "dao-jun (via GitHub)" <gi...@apache.org>.
dao-jun commented on code in PR #23995:
URL: https://github.com/apache/pulsar/pull/23995#discussion_r1959627097


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/LeaderElectionImpl.java:
##########
@@ -113,6 +116,11 @@ private synchronized CompletableFuture<LeaderElectionState> elect() {
                 return tryToBecomeLeader();
             }
         }).thenCompose(leaderElectionState -> {
+            synchronized (this) {
+                if (internalState == InternalState.Closed) {

Review Comment:
   Need to add `volatile` on `internalState`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][meta] Stop election operations when LeaderElectionImpl gets closed [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #23995:
URL: https://github.com/apache/pulsar/pull/23995#discussion_r1959665979


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/LeaderElectionImpl.java:
##########
@@ -113,6 +116,11 @@ private synchronized CompletableFuture<LeaderElectionState> elect() {
                 return tryToBecomeLeader();
             }
         }).thenCompose(leaderElectionState -> {
+            synchronized (this) {
+                if (internalState == InternalState.Closed) {

Review Comment:
   Already covered with `synchronized (this)`. `this` points to `LeaderElectionImpl` instance here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][meta] Stop election operations when LeaderElectionImpl gets closed [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #23995:
URL: https://github.com/apache/pulsar/pull/23995#issuecomment-2665799107

   Fixing a potentially flaky test that uses a bad way to trigger leader election.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][meta] Stop election operations when LeaderElectionImpl gets closed [pulsar]

Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat closed pull request #23995: [improve][meta] Stop election operations when LeaderElectionImpl gets closed
URL: https://github.com/apache/pulsar/pull/23995


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][meta] Stop election operations when LeaderElectionImpl gets closed [pulsar]

Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat commented on PR #23995:
URL: https://github.com/apache/pulsar/pull/23995#issuecomment-6160098146

   Fixed in #26879


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org