You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2021/07/23 09:15:54 UTC

[dubbo] branch 2.6.x updated: Backport 2.7, lazy connection warn log (#8329)

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

liujun pushed a commit to branch 2.6.x
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/2.6.x by this push:
     new 5e68e43  Backport 2.7, lazy connection warn log (#8329)
5e68e43 is described below

commit 5e68e439122f1f9063ae6784e3d39484e684b503
Author: ken.lj <ke...@gmail.com>
AuthorDate: Fri Jul 23 17:15:03 2021 +0800

    Backport 2.7, lazy connection warn log (#8329)
---
 .../java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java    | 4 +++-
 .../alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java | 2 +-
 .../dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java      | 6 ++----
 .../dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClientTest.java  | 3 +--
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java
index 017e4a9..262ab70 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java
@@ -437,6 +437,9 @@ public class DubboProtocol extends AbstractProtocol {
                 }
             }
         }
+        // put here to reduce the chance of accepting new invocation after client closed.
+        // close invoker and then client.
+        super.destroy();
 
         for (String key : new ArrayList<String>(referenceClientMap.keySet())) {
             ExchangeClient client = referenceClientMap.remove(key);
@@ -466,6 +469,5 @@ public class DubboProtocol extends AbstractProtocol {
             }
         }
         stubServiceMethodsMap.clear();
-        super.destroy();
     }
 }
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java
index 235af39..bc230a2 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java
@@ -115,7 +115,7 @@ final class LazyConnectExchangeClient implements ExchangeClient {
     private void warning(Object request) {
         if (requestWithWarning) {
             if (warningcount.get() % 5000 == 0) {
-                logger.warn(new IllegalStateException("safe guard client , should not be called ,must have a bug."));
+                logger.warn(url.getAddress() + " " + url.getServiceKey() + " safe guard client get called after real client closed, recreating connection...");
             }
             warningcount.incrementAndGet();
         }
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
index 4a6e965..caed500 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
@@ -167,11 +167,9 @@ final class ReferenceCountExchangeClient implements ExchangeClient {
     private LazyConnectExchangeClient replaceWithLazyClient() {
         // this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
         URL lazyUrl = url.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.TRUE)
-                .addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
                 .addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
-                .addParameter("warning", Boolean.TRUE.toString())
-                .addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
-                .addParameter("_client_memo", "referencecounthandler.replacewithlazyclient");
+                .addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
+
 
         String key = url.getAddress();
         // in worst case there's only one ghost connection.
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClientTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClientTest.java
index d9b64c2..452e6a9 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClientTest.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClientTest.java
@@ -26,7 +26,6 @@ import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
 import com.alibaba.dubbo.rpc.Exporter;
 import com.alibaba.dubbo.rpc.Invoker;
 import com.alibaba.dubbo.rpc.ProxyFactory;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -46,7 +45,7 @@ public class ReferenceCountExchangeClientTest {
     IHelloService helloService;
     ExchangeClient demoClient;
     ExchangeClient helloClient;
-    String errorMsg = "safe guard client , should not be called ,must have a bug";
+    String errorMsg = "safe guard client";
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {