sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.95k stars 1.26k forks source link

Biz sofa service shutdown order problem #506

Closed quhw closed 4 years ago

quhw commented 4 years ago

Describe the bug

背景:业务模块在主模块注册了业务路由信息,供主模块做业务路由选择。业务模块卸载时,需要通知主模块,主模块后续就不再路由到该业务模块。

问题:业务模块监听了SOFA的ApplicationShutdownCallback,在shutdown()回调中通过SOFA服务调用主模块的unregister()服务。但是看起来ARK的销毁顺序有问题,这个时候主模块的SofaReference已经被销毁了,导致无法unregister,主模块一直调用不存在的业务模块服务。

期望:shutdown()结束后再销毁reference,在sofa dynamic module中是正常的。

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

sofastack-bot[bot] commented 4 years ago

Hi @quhw, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

Describe the bug Background: The service module registers service routing information in the main module for the main module to do service routing. When the service module is uninstalled, the main module needs to be notified, and the main module is no longer routed to the service module. Problem: The business module listens to SOFA's ApplicationShutdownCallback and calls the main module's unregister() service via the SOFA service in the shutdown() callback. However, it seems that the destruction order of ARK is problematic. At this time, the SofaReference of the main module has been destroyed, which makes it impossible to unregister. The main module always calls the service module service that does not exist. Expectation: destroy the reference after the end of shutdown(), which is normal in the sofa dynamic module. ### Expected behavior ### Actual behavior ### Steps to reproduce ### Minimal yet complete reproducer code (or GitHub URL to code) ### Environment - SOFAArk version: 1.0.0 - JVM version (eg java - Version): - OS version (eg uname -a): - Maven version: - IDE version:

caojie09 commented 4 years ago

We should shutdown RuntimeShutdownAware first, then shutdown ComponentManager.