zrlw opened a new issue #8805:
URL: https://github.com/apache/dubbo/issues/8805
### Environment
* Dubbo version: 3.0
github集成构建DubboShutdownHook线程抛IllegalStateException: Shutdown in
progress,并且近期出现的频率越来越频繁:
```
2021-09-15T03:06:39.5680207Z ##[error]Exception in thread
"DubboShutdownHook" java.lang.RuntimeException:
java.lang.IllegalStateException: Shutdown in progress
2021-09-15T03:06:39.5694633Z at
org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:48)
2021-09-15T03:06:39.5697163Z at
org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:72)
2021-09-15T03:06:39.5699110Z at
java.lang.Iterable.forEach(Iterable.java:75)
2021-09-15T03:06:39.5700893Z at
org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:72)
2021-09-15T03:06:39.5703192Z at
org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:89)
2021-09-15T03:06:39.5705079Z at
org.apache.dubbo.config.DubboShutdownHook.run(DubboShutdownHook.java:76)
2021-09-15T03:06:39.5706254Z Caused by: java.lang.IllegalStateException:
Shutdown in progress
2021-09-15T03:06:39.5707469Z at
java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82)
2021-09-15T03:06:39.5709546Z at
java.lang.Runtime.removeShutdownHook(Runtime.java:239)
2021-09-15T03:06:39.5711564Z at
org.apache.dubbo.config.DubboShutdownHook.unregister(DubboShutdownHook.java:115)
2021-09-15T03:06:39.5714856Z at
org.apache.dubbo.config.bootstrap.DefaultApplicationDeployer.unRegisterShutdownHook(DefaultApplicationDeployer.java:162)
2021-09-15T03:06:39.5718071Z at
org.apache.dubbo.config.bootstrap.DefaultApplicationDeployer.destroy(DefaultApplicationDeployer.java:849)
2021-09-15T03:06:39.5720445Z at
org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:46)
```
看了代码是ApplicationShutdownHooks的remove方法判断hooks集合空所致:
```
if(hooks == null)
throw new IllegalStateException("Shutdown in progress");
```
问题:
1. DubboShutdownHook代码搞的是多实例,但类上的注解还在说单例:
```
This is a singleton in order to ensure there is only one shutdown hook
registered. Because {@link ApplicationShutdownHooks} use {@link
java.util.IdentityHashMap} to store the shutdown hooks.
```
2.
日志内容没有完整堆栈信息,所以不知道什么触发的org.apache.dubbo.common.function.ThrowableAction.execute,以及为什么此时ApplicationShutdownHooks的hooks已经为空。
在ShutdownHookCallbacks的callback()的循环里加try-catch可以解决构建失败问题:
```
private static final Logger logger =
LoggerFactory.getLogger(ShutdownHookCallbacks.class);
public void callback() {
getCallbacks().forEach(callback -> {
try {
execute(callback::callback);
} catch (Exception e) {
logger.warn("callback exception.", e);
}
});
}
```
只是现在构建会频繁出现这个问题的原因是什么?
PS:
master分支的上述代码和3.0基本相同,不清楚是否存在类似的问题。
--
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]