AlexStocks commented on issue #3640: URL: https://github.com/apache/dubbo-go/issues/3640#issuecomment-5248899342
这个 Issue 可以采纳,按 P1 处理。目前已经分配给你。 我核对了当前 `main`(`48d6e696e755d46df2425bbf71c413bbd1887f3f`)的实现,并分别验证了 TCP 端口被占用和 UDP 端口被占用两种路径:失败侧会立即返回 bind error,另一侧仍继续监听,`errgroup.Wait()` 因等待全部 goroutine 退出而无法返回;调用 `Stop()` 后 `Run()` 才会结束。因此核心问题成立,是双协议启动过程中的生命周期管理和资源清理缺陷。 不过有两点需要调整: 1. 标题中的 “Memory Leak” 建议改为 “Resource Leak” 或 “Startup Hang”。现有证据能确认 listener、端口和 goroutine 被持续占用,但还不足以证明存在不可回收且持续增长的内存泄漏。上层目前是在 goroutine 中调用 `Run()`,所以生产影响也不只是调用方阻塞,还包括服务部分启动、错误未及时反馈以及资源持续占用。 2. Proposed Fix 的“预绑定 TCP/UDP socket”方向可以解决启动阶段的端口冲突,但还不能完整解决生命周期问题。两个 socket 都绑定成功以后,如果任一 `Serve` 异常退出,必须主动关闭另一侧并等待两个 goroutine 都结束;仅改成 `errgroup.WithContext` 不够,因为监听中的 `Serve` 不会仅凭 context 自动退出。 实现时还需要注意: - 外部创建的 TCP listener 和 UDP `PacketConn` 要明确所有权,并在预绑定失败、任一 Serve 失败、`Stop` 和 `GracefulStop` 路径中保证释放;`http3.Server.Serve(conn)` 不会替调用方关闭传入的连接。 - `net.ListenUDP` 的第二个参数是 `*net.UDPAddr`,不能直接传 `s.addr` 字符串;可以使用 `net.ResolveUDPAddr` + `net.ListenUDP`,或者 `net.ListenPacket`。 - TLS readiness 检查需要同时支持 `Certificates`、`GetCertificate` 和 `GetConfigForClient`。 - 请补充以下回归测试:TCP 被占用、UDP 被占用、TLS 配置没有可用证书、绑定成功后任一 Serve 异常退出、`Stop`/`GracefulStop` 后 TCP 和 UDP 端口均可重新绑定,以及相关 race 测试。 另外,#3639 正在修改同一个 Server 的生命周期字段访问,但它只处理并发访问问题,不会修复本 Issue;实现时需要协调或 rebase,避免覆盖其中的 atomic pointer 修改。 -- 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]
