-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Summary of several issues of graceful shutdown #2435
Comments
Please try 2.6.3, it contains the fix just as you described. |
This has been fixed in the new version, now temporarily closed, open anyway if there is a problem |
确实我看到2.6.3版本有相关修改,基本和我描述思路一致,有几个问题问题: |
Please consider scenarios where Dubbo may be used without Spring.
Again, please consider scenarios where Dubbo may be used without Spring. Please note that the core design principles of Dubbo is that the core should not have strong dependency to other framework like Spring.
Which destroyAll method do you exactly mean? I can't find the logic you mentioned. |
2.6.1public static void destroyAll() {
if (!destroyed.compareAndSet(false, true)) {
return;
}
AbstractRegistryFactory.destroyAll();
// Wait for registry notification
try {
Thread.sleep(ConfigUtils.getServerShutdownTimeout());
} catch (InterruptedException e) {
logger.warn("Interrupted unexpectedly when waiting for registry notification during shutdown process!");
}
ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
for (String protocolName : loader.getLoadedExtensions()) {
try {
Protocol protocol = loader.getLoadedExtension(protocolName);
if (protocol != null) {
protocol.destroy();
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
}
} 2.6.2 // TODO: 2017/8/30 to move this method somewhere else
public static void destroyAll() {
if (!destroyed.compareAndSet(false, true)) {
return;
}
AbstractRegistryFactory.destroyAll();
ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
for (String protocolName : loader.getLoadedExtensions()) {
try {
Protocol protocol = loader.getLoadedExtension(protocolName);
if (protocol != null) {
protocol.destroy();
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
}
} |
No, if you are using Dubbo 2.6.3 with Spring, Dubbo's Shutdown hook should never be registered. For question 3, I am not aware of that change. Looking at the history, it seems to be introduced by d290529. @zonghaishang Do you have any idea why we are change this? |
@ralf0131 |
@rangtao What framework are you using? Expected behavior:
If you have found something unexpected, please file an issue and provide steps to reproduce. |
see HeaderExchangeServer#isRunning:
If there is a client connection, it will automatically wait, there was a bug before, so will invoke sleep |
one further comments on #2435 (comment):
|
我们在测试及生产环境下总结目前Dubbo优雅停机问题存在几个问题:
[1]Spring可能先于框架关闭,导致业务服务无法正确执行完成;
[2]tomcat+spring场景,中间件停机可能会导致class被回收,导致log日志无法输出,甚至报class not found;
[3]如果存在多个hook,如spring本身有hook,无法保证hook执行顺序;
[4]zk在大数据量同步通知下延迟严重,导致注销后仍有请求(目前版本简单sleep了一下);
[5]停机时间无法设置,官方关于“停机设置标志位”的描述有误。
综上所述,我们的优化作法是将框架的优雅停机委托给Spring管理,通过监听Spring的close事件触发停机,这样做有两个好处:(1)保证框架停机优于Spring关闭;(2)应用用起来简单,只需要维护Spring生命周期;(3)相对于hook方式,主动调用停机接口更让人放心。
The text was updated successfully, but these errors were encountered: