Alanxtl opened a new issue, #3107: URL: https://github.com/apache/dubbo-go/issues/3107
### ✅ 验证清单 - [x] 🔍 我已经搜索过 [现有 Issues](https://github.com/apache/dubbo-go/issues),确信这不是重复问题 ### 🚀 Go 版本 1.24 ### 📦 Dubbo-go 版本 3.3.1 ### 🖥️ 服务端配置 _No response_ ### 💻 客户端配置 _No response_ ### 🌐 协议配置 _No response_ ### 📋 注册中心配置 nacos 2.1.2 ### 💾 操作系统 🐧 Linux ### 📝 Bug 描述 在使用 **dubbo-go + Nacos** 时,发现一个比较严重的问题: 当服务 **收到 kill / SIGINT / SIGTERM 信号并触发优雅下线流程** 时, **服务并没有在 Nacos 中正常下线(注销实例)**。 ### 🔄 重现步骤 1. 本地启动一个最简单的 **Triple Server** 2. 服务启动成功并成功注册到 Nacos 3. 向服务进程发送 `SIGINT` / `SIGTERM`(例如 `kill -2 pid` 或 Ctrl+C) 4. 服务进程打印如下日志并退出: ```text Graceful shutdown --- Destroy all registriesConfig ``` 5. **在服务完全退出前后,Nacos 控制台中该实例仍然存在** ### ✅ 预期行为 在收到 kill 信号并执行 graceful shutdown 时: - 服务应当 主动调用 Nacos 的 UnRegister / Deregister 接口 - 实例应当在 Nacos 中及时下线,而不是一直保留直到心跳超时 ### ❌ 实际行为 - graceful shutdown 日志正常打印 - 但 Nacos 中的服务实例未被注销 - 实例只能在一段时间后依赖 Nacos 心跳超时被动下线 ### 💡 可能的解决方案 本地断点调试发现,在优雅下线过程中,会走到如下代码: ```go func (s *serviceDiscoveryRegistry) UnRegister(url *common.URL) error { if !shouldRegister(url) { return nil } return nil } ``` 从当前实现来看: * `UnRegister` 方法内部 **并未真正调用 Nacos 的 `UnRegisterService` / `DeregisterInstance`** * 方法直接返回 `nil` * 实际上并没有执行任何注销逻辑 看起来 graceful shutdown 的流程 **只销毁了 registry 配置(Destroy all registriesConfig)**, 但并没有真正执行注册中心的反注册操作。 ## Questions 1. 目前 dubbo-go 的设计是否是 **依赖注册中心心跳超时**,而不是在 shutdown 时主动注销? 2. 如果是期望主动注销: * 这里是否是一个遗漏 / Bug? * `UnRegister` 是否应该显式调用 Nacos 的 `UnRegisterService`? 3. 是否有推荐的 **正确优雅下线方式**,可以确保实例在 kill 信号后立刻从 Nacos 下线? -- 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]
