-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
ReferenceConfig initialized not changed to false once subscribe throws exception #4067
Conversation
Hi, I could not reproduce the issue you are describing. I want to make sure I understand correctly. My demo Consumer code: public static void main(String[] args) {
ReferenceConfig<DemoService> referenceConfig = new ReferenceConfig<>();
referenceConfig.setApplication(new ApplicationConfig("demo-consumer"));
referenceConfig.setRegistry(new RegistryConfig("nacos://127.0.0.1:8848"));
referenceConfig.setInterface(DemoService.class);
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
while(true) {
try {
Thread.sleep(3000);
DemoService demoService = cache.get(referenceConfig);
String hello = demoService.sayHello("world");
System.out.println("result: " + hello);
} catch (Exception e) {
e.printStackTrace();
}
}
} Steps I tried:
The behavior looks correct, so what is your actually issue? |
@ralf0131 , what's the registry for you? zookeeper cannot reproduce the issue, as it won't throw exception even no provider exists. You can reproduce it once you have thrown exception from the service subscribe. |
I used Nacos as registry, please refer to my consumer code. What registry did you use? Did you have other configuration such as xml? Please attach them as well. |
It's our own registry. Your consumer code is ok. Will Nacos throw exception if no providers? You can reproduce it, when registry throws out exception with no providers as below.
|
Throw out exception from registry is just part of my points. We cannot predict any exception from the consumer initialization. Currently, initialized flag have been set to false only if invoker initialized. But the invoker maybe not able to be initialized, as any exception could be thrown from below extension.
|
Yes, it will throw exception, the stack trace is attached in my previous comment. However, when the provider is on, the consumer can receive response from provider. This behavior is different from what you are describing.
Where is these lines of code? Is it your customized code that not belong to Dubbo? |
Yes, we have extend it with our own registry. |
Again, where is the line of code? Could you specify the location? I suggest you give a complete example instead, rather that the code snipped. |
Could you try with some open source registry like ZK or Nacos? Why they are working? If the error is only happen with your own registry. I think it is something that you should improve your own registry. |
It's dubbo's code. When refprotocol.refer throws exception, initialized cannot be set to false. My example cannot work in your side, as it relies our company's registry.
|
I have tried ZK, cannot reproduce as ZK won't throw exception without providers. Let's talk about it in DingDign, my account is haiyang198542. |
I think I have got what you mean, I am trying to reproduce in my local env. |
Hi, I did some tweak in my local env and successfully reproduced the issue you describe. What I did in if (!directory.isAvailable()) {
throw new RpcException("test");
} I confirmed your proposed change works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the pull request!
What is the purpose of the change
fix issue #4068
ReferenceConfigCache is able to initialize ReferenceConfig for multiple times. It cannot set initialize to false once subscribe throws exception.
Brief changelog
Set initialized to true after the init finished. Currently, initialized has not been changed to false, if refprotocol.refer throws exception.
Verifying this change
Note:
Found another existing issue, that the urls would cause OOM once retries again and again without service provider. I will consider and send another PR for this.
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.