zhangjh opened a new issue, #10058:
URL: https://github.com/apache/dubbo/issues/10058

   <!-- If you need to report a security issue please visit 
https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) 
of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 2.7.7
   * Operating System version: k8s+docker+linux
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   I'm not sure it is a bug already knew/reported or just a feature problem can 
not be solved.
   
   When dubbo client shutdown, we all know dubbo will run the 
`DubboShutdownHook` class to shutdow gracefully. In that progress, there may 
some requests not finished, I occured a situation that the consumer instance 
throws exception as `RpcException("No provider available in " + invokers);`
   
   1. In order to reproduce the problem, we should use multiple registies first:
   ```
   // dubbo consumer config
   dubbo.registries.a.address=zookeeper://xxx
   dubbo.registries.b.address=zookeeper://xxx
   ```
   2. then add the breakpoint at the dubbo consumer method call, such as:
   `demoService.sayHello(name);` and add the breakpoint at 
`org.apache.dubbo.config.DubboShutdownHook#destroyAll` yet
   (breakpoint must be thread level so that you switch thread whe debugging)
   
   
![image](https://user-images.githubusercontent.com/3371714/169288759-ba5b1ae0-66fe-4261-949c-8929c4e87d05.png)
   
   3. then run command `kill or kill -15` to trigger dubbo instance shutdown, 
   ```
   ps -ef | grep java | grep "org.apache.dubbo.demo.consumer.Application" | awk 
'{print $2}' | xargs kill -15
   ```
   4. when thread suspend on 
`org.apache.dubbo.config.DubboShutdownHook#destroyAll`, switch debug thread to 
main thread, step debuggind to 
`org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker#invoke`, there 
produce a invoker list.
       They are all available now.
   
![image](https://user-images.githubusercontent.com/3371714/169289295-28b0fb4a-b0e1-4f3c-b1eb-a43b9697fdf3.png)
   6. then switch debug thread to dubboShutdownHook, step debug to "destroyAll" 
method, and let it run finish. When `destroyProtocols` run finish, the variable 
`org.apache.dubbo.rpc.cluster.directory.AbstractDirectory#destroyed` will be 
set `true`.
   7. then switch debug thread to main again. The invokers get before now not 
available! Because the invoker.isAvailable() will check the variable 
`org.apache.dubbo.rpc.cluster.directory.AbstractDirectory#destroyed`. 
   8. Let the debug step over, it will enter in 
`org.apache.dubbo.rpc.cluster.support.registry.ZoneAwareClusterInvoker#doInvoke`.
 In this method, invokers will be checked available again. So a RpcException 
throws at last.
   
![image](https://user-images.githubusercontent.com/3371714/169290956-0d6c9224-4a76-447f-922d-b1e0979ad079.png)
   
   
   ### Expected Behavior
   Do you think sleep shutdown timeout after destroy the registries, then run 
destroyProtocols will solve this problem?
   Give some timeout to let the requests remaining to run finish.
   
![image](https://user-images.githubusercontent.com/3371714/169292223-fc401877-cbd8-45a8-8daf-de5f7c534a23.png)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to