Skip to content
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

Backport 2.7, lazy connection warn log #8329

Merged
merged 3 commits into from Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -437,6 +437,9 @@ public void destroy() {
}
}
}
// 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);
Expand Down Expand Up @@ -466,6 +469,5 @@ public void destroy() {
}
}
stubServiceMethodsMap.clear();
super.destroy();
}
}
Expand Up @@ -115,7 +115,7 @@ public ResponseFuture request(Object request, int timeout) throws RemotingExcept
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();
}
Expand Down
Expand Up @@ -167,11 +167,9 @@ public void startClose() {
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.
Expand Down
Expand Up @@ -26,7 +26,6 @@
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;
Expand All @@ -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 {
Expand Down