This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new b23fd38  Fix Dubbo zookeeper registry failed to re-subscribe (#7669)
b23fd38 is described below

commit b23fd38b30a33a4b3fcaef54903fdc9a4541650d
Author: xiaoheng1 <[email protected]>
AuthorDate: Wed May 5 20:25:18 2021 +0800

    Fix Dubbo zookeeper registry failed to re-subscribe (#7669)
---
 .../java/org/apache/dubbo/registry/support/FailbackRegistry.java   | 7 ++++++-
 .../org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java     | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java
index 6d82c05..f920755 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java
@@ -144,7 +144,7 @@ public abstract class FailbackRegistry extends 
AbstractRegistry {
         }
     }
 
-    private void removeFailedSubscribed(URL url, NotifyListener listener) {
+    public void removeFailedSubscribed(URL url, NotifyListener listener) {
         Holder h = new Holder(url, listener);
         FailedSubscribedTask f = failedSubscribed.remove(h);
         if (f != null) {
@@ -381,6 +381,9 @@ public abstract class FailbackRegistry extends 
AbstractRegistry {
                 logger.info("Recover register url " + recoverRegistered);
             }
             for (URL url : recoverRegistered) {
+                // remove fail registry or unRegistry task first.
+                removeFailedRegistered(url);
+                removeFailedUnregistered(url);
                 addFailedRegistered(url);
             }
         }
@@ -393,6 +396,8 @@ public abstract class FailbackRegistry extends 
AbstractRegistry {
             for (Map.Entry<URL, Set<NotifyListener>> entry : 
recoverSubscribed.entrySet()) {
                 URL url = entry.getKey();
                 for (NotifyListener listener : entry.getValue()) {
+                    // First remove other tasks to ensure that 
addFailedSubscribed can succeed.
+                    removeFailedSubscribed(url, listener);
                     addFailedSubscribed(url, listener);
                 }
             }
diff --git 
a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
 
b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
index 8f8e8d5..80edcc7 100644
--- 
a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
+++ 
b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
@@ -308,6 +308,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
             for (Map.Entry<URL, Set<NotifyListener>> entry : 
recoverSubscribed.entrySet()) {
                 URL url = entry.getKey();
                 for (NotifyListener listener : entry.getValue()) {
+                    removeFailedSubscribed(url, listener);
                     addFailedSubscribed(url, listener);
                 }
             }

Reply via email to