You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/24 23:28:01 UTC

[GitHub] [pulsar] merlimat opened a new pull request #12184: PIP-45: Handle session events and invalidations from single thread

merlimat opened a new pull request #12184:
URL: https://github.com/apache/pulsar/pull/12184


   ### Motivation
   
   When we receive session events from the MetadataStoreExtended implementation, we need to process them from a single thread to ensure that the locks and leader revalidations are not happening concurrently. 
   
   For example, it possible to receive a `SessionEvent.Reconnected` immediately followed by a `SessionEvent.SessionReestablished`. In this case we need to first finish processing the 1st event and complete all the revalidations, then proceeding to the other event, otherwise we'll be having multiple revalidations in flight.


-- 
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



[GitHub] [pulsar] merlimat merged pull request #12184: PIP-45: Handle session events and invalidations from single thread

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #12184:
URL: https://github.com/apache/pulsar/pull/12184


   


-- 
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



[GitHub] [pulsar] merlimat commented on a change in pull request #12184: PIP-45: Handle session events and invalidations from single thread

Posted by GitBox <gi...@apache.org>.
merlimat commented on a change in pull request #12184:
URL: https://github.com/apache/pulsar/pull/12184#discussion_r716048218



##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/LeaderElectionImpl.java
##########
@@ -269,15 +275,19 @@ public synchronized LeaderElectionState getState() {
     }
 
     private synchronized void handleSessionNotification(SessionEvent event) {
-        if (event == SessionEvent.SessionReestablished) {
-            if (leaderElectionState == LeaderElectionState.Leading) {
+        // Ensure we're only processing one session event at a time.
+        executor.execute(SafeRunnable.safeRun(() -> {

Review comment:
       Yes, it doesn't make sense anymore




-- 
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



[GitHub] [pulsar] eolivelli commented on a change in pull request #12184: PIP-45: Handle session events and invalidations from single thread

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #12184:
URL: https://github.com/apache/pulsar/pull/12184#discussion_r716010182



##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/LeaderElectionImpl.java
##########
@@ -269,15 +275,19 @@ public synchronized LeaderElectionState getState() {
     }
 
     private synchronized void handleSessionNotification(SessionEvent event) {
-        if (event == SessionEvent.SessionReestablished) {
-            if (leaderElectionState == LeaderElectionState.Leading) {
+        // Ensure we're only processing one session event at a time.
+        executor.execute(SafeRunnable.safeRun(() -> {

Review comment:
       Should we remove 'synchronized' ?




-- 
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