-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
【dubbo优雅关机】关于spring管理的应用重复监听处理dubbo关闭。 #7093
Comments
xiaoheng1
added a commit
to xiaoheng1/incubator-dubbo
that referenced
this issue
Mar 3, 2021
…onitoring processing dubbo shutdown.
This was referenced Mar 3, 2021
Merged
Closed
xiaoheng1
added a commit
to xiaoheng1/incubator-dubbo
that referenced
this issue
Mar 21, 2021
…onitoring processing dubbo shutdown.
xiaoheng1
added a commit
to xiaoheng1/incubator-dubbo
that referenced
this issue
Mar 21, 2021
…onitoring processing dubbo shutdown.
Closed
6 tasks
xiaoheng1
added a commit
to xiaoheng1/incubator-dubbo
that referenced
this issue
Mar 21, 2021
…onitoring processing dubbo shutdown.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Steps to reproduce this issue
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
dubbo彻底关闭(提示DubboBootstrap is about to shutdown...)后再关闭数据库连接池,这样给没有处理完的dubbo线程使用数据库连接的机会。
Actual Result
dubbo没有关闭完,数据库连接池已经关闭,导致应用并发高的时候很多没跑完的dubbo线程拿不到数据库连接抛出异常。
If there is an exception, please attach the exception trace:
msg:DUBBO服务异常 remoteHost:xxx.xx.xxx.xxx service:com.xxx.service.xxxService method:xxx message:nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
原因是spring管理的应用dubbo启动的时候同时开启了两个关闭dubbo服务的入口,一个在DubboBootstrap中
另外一个是DubboBootstrapApplicationListener中通过监听spring的关闭事件来关闭dubbo服务
数据源关闭是spring关机钩子处理。
通过DubboBootstrap注册的DubboShutdownHook是单独的一个线程,不与spring关机钩子阻塞执行,spring发送ContextClosedEvent后会继续执行关闭数据源连接池的动作。
通过监听ContextClosedEvent是使用的spring的关机钩子线程,会阻塞执行关闭dubbo后再继续执行关闭数据源连接池的动作。
临时解决方法:
通过在spring启动的方法中显示调用DubboBootstrap.getInstance().unRegisterShutdownHook();关闭DubboBootstrap自动注册的DubboShutdownHook。只保留监听ContextClosedEvent关闭dubbo服务。
优雅处理探讨:
是否不应该在DubboBootstrap创建的时候注册DubboShutdownHook。或者在SpringExtensionFactory中判断注册了spring的关机钩子就调用DubboBootstrap.getInstance().unRegisterShutdownHook();关闭DubboBootstrap自动注册的DubboShutdownHook。查看SpringExtensionFactory中历史代码,以前是类似的做法,在dubbo2.7.5版本去掉了。去掉设计参考#5504
The text was updated successfully, but these errors were encountered: