dubbo
dubbo copied to clipboard
[Bug] Graceful Shutdown in dubbo-2.7.22 Has a Bug
Pre-check
- [X] I am sure that all the content I provide is in English.
Search before asking
- [X] I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
2.7.22 However, I found that versions 2.7.7 through 2.7.23 all have this bug, while version 2.7.3 does not have this bug.
Steps to reproduce this issue
When integrating Dubbo 2.7.22 in a Spring Boot project, and using dubbo:reference in dubbo.xml similar to: <dubbo:reference interface="com.xdd.test.demo44.remote.IUserServiceRemote" id="userServiceRemote"/>
After starting the Spring Boot application, you will observe that the java.lang.ApplicationShutdownHooks.hooks variable contains an additional DubboShutdownHook object.
What you expected to happen
In the Dubbo consumer application, it can wait for the tasks to complete upon shutdown, up to a timeout of 10 seconds, rather than directly interrupting the tasks in progress.
Anything else
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean first executes DubboShutdownHook.getDubboShutdownHook().unregister(). During the process of setting properties for the bean, org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean then executes DubboShutdownHook.getDubboShutdownHook().register().
The order is reversed, causing the DubboShutdownHook to persist after the consumer starts. When the consumer stops, the DubboShutdownHook may execute before the SpringApplicationShutdownHook, directly shutting down tasks that haven't finished executing. This results in the "Interrupted unexpectedly while waiting for" exception.
This bug also exists in dubbo-2.7.23.
I seem to have seen a similar issue, but not in this version: https://github.com/apache/dubbo/issues/7093. My current solution is to directly call DubboShutdownHook.getDubboShutdownHook().unregister() after the Spring Boot application starts.
My English is not very good, but you can check the original link in Chinese: https://github.com/apache/dubbo/issues/14488
Are you willing to submit a pull request to fix on your own?
- [X] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct