dubbo关闭流程问题
- Dominant language
- Java
- Stars
- 41.6k
- Forks
- 26.4k
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 4
Description
dubbo在关闭的时候 可能会造成服务响应报错和自身调用错误
dubbo关闭流程在这个类中 DubboShutdownHook.destroyAll 2.6.11版本
1 AbstractRegistryFactory.destroyAll();//函数会关闭注册中 下掉自身的注册 然后立刻进行
2 protocol.destroy();//关闭对外服务server 和client
当A节点执行完步骤2后 B节点尚未接收到注册中心的通知,
这时B节点还可能访问A节点,此时A的服务已关闭导致B报错/重试
所以关闭流程需要改为如下方案
1 节点先关闭自身的注册(仅unregister),但是同时还保持监听其他节点变化的通知
2 等待一定时间,防止其他节点接收注册中心通知慢
3 关闭所有Protocol的server
4 等待一定时间,防止内部还有自动任务/线程等其他操作还需要使用rpc调用其他节点
5 关闭所有Protocol的client
6 关闭注册中心的节点变化监听
这样可以保证关闭流程中尽量减少其他节点调用错误的情况和保证服务本身可用优雅关闭
其中3,4,5步骤可以合一
2,4步骤建议可以配置或者提供接口,支持使用者实现接口进行流程阻塞等待
Contributor guide
Research direction
Start with DubboShutdownHook.destroyAll in the 2.6.11 shutdown flow, then read AbstractRegistryFactory.destroyAll and protocol.destroy to map registration, server, client, and listener shutdown. The change is done when shutdown ordering avoids calls to already-closed services and the proposed waiting periods can be configured or supplied through an interface, as described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100