AlexStocks commented on code in PR #980:
URL: https://github.com/apache/dubbo-go-pixiu/pull/980#discussion_r4522107910


##########
pkg/server/listener_manager.go:
##########
@@ -117,11 +117,15 @@ func (lm *ListenerManager) gracefulShutdownInit() {
                sig := <-signals
                logger.Infof("get signal %s, dubbo-go-pixiu will start 
shutdown.", sig)
 
-               time.AfterFunc(timeout, func() {
+               timer := time.AfterFunc(timeout, func() {
                        logger.Warn("Shutdown gracefully timeout, listeners 
will shutdown immediately. ")
                        os.Exit(0)
                })
 
+               // Stop discovery/config watches before draining, so they 
cannot publish
+               // new resources during shutdown. The timer still bounds the 
whole path.
+               shutdown.RunHooks()

Review Comment:
   定级更正为 P2:本 PR 同步了 #982 的提交,而 #982 正文的 "Upgrade and shutdown requirements" 
已明确写明 `Enable graceful signal cleanup with a positive 
static_resources.shutdown_config.timeout. The existing default 0s disables that 
signal handler.`,因此这是已披露的设计取舍,不按「遗漏缺陷」定级。保留三点仍成立的事实供后续跟进。
   
   **1) 该清理路径在默认配置下不可达(可达性证据)**
   
   `shutdown.RunHooks()` 全仓库只有本行这一个调用点,它位于 `gracefulShutdownInit` 中 `if timeout 
<= 0 { return }` 之后:
   
   ```go
   timeout := sdc.GetTimeout()   // ShutdownConfig.Timeout 默认 "0s"
   if timeout <= 0 {
       return
   }
   signals := make(chan os.Signal, 1)
   signal.Notify(signals, shutdown.ShutdownSignals...)
   ```
   
   未配置 `shutdown_config.timeout` 时 `GetShutdownConfig()` 使用 `Timeout: 
"0s"`(`pkg/model/bootstrap.go`),于是 `signal.Notify` 不执行 → 本行不执行 → 
`s.adapterManager.Stop`(`pkg/server/pixiu_start.go` 注册)不执行 → 各 adapter 不 
`Unsubscribe` → `DoUnsubscribe()` 里新加的 `CloseClient()`/`Close()` 不被调用;未释放的资源是 
nacos v2 naming/config client 的 gRPC 连接及其内部重试 goroutine。`pkg/cmd/gateway.go` 的 
`deploy.stop()` 是另一条同样不可达的路径(`server.Start` 尾部 `blockForever()` 不返回)。
   
   **2) 该行为没有测试钉子**
   
   新增用例都在非零 timeout 下运行(`pkg/server/listener_manager_test.go` 用 `Timeout: 
"1h"`,`pkg/cmd/gateway_shutdown_test.go` 用 `"2s"`)。`timeout <= 0` 
时「不注册信号处理器、不执行 hooks」这个被文档化的行为没有任何断言,后续改动 `gracefulShutdownInit` 
时容易在无人察觉的情况下改变它。建议补一条 `Timeout: "0s"` 的用例把现状钉住。
   
   **3) 本 PR 正文未继承这条升级前置条件**
   
   #982 正文写了 Nacos 2.x 端口要求与 timeout 前置条件,本 PR 正文只说明「请先合并 #982」。若 #982 
先合入则用户引导由 #982 承担;若本 PR 单独合入,这批关闭代码的启用条件在正文里没有任何说明。按本仓库 
`PULL_REQUEST_TEMPLATE.md` 的要求,这类需要用户额外操作的内容应写在 ```release-note 块内并含 `action 
required`。该项不在本行,只在评审结论中记录。
   



-- 
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]

Reply via email to