man-mu commented on code in PR #3701:
URL: https://github.com/apache/dubbo-go/pull/3701#discussion_r3849304142


##########
filter/accesslog/filter.go:
##########
@@ -431,6 +437,13 @@ func (f *Filter) shutdown() {
                        close(f.logChan)
                }
 
+               // Wait for processLogs to exit (drainLogs timeout is 5s, use 
6s margin)
+               select {
+               case <-f.done:
+               case <-time.After(shutdownWaitTimeout):
+                       logger.Warn("[Filter][AccessLog] shutdown wait for 
processLogs timeout")
+               }
+
                // Close all cached file handles

Review Comment:
   感谢详细的 review!已按建议重构 shutdown 路径:
   
   - 删除了 `writeLogToFileWithTimeout` 中的额外写入 goroutine,`processLogs` 
直接写文件,`done` 信号即代表所有写入完成
   - `drainLogs` 改用绝对 deadline 代替 timer
   - 不再 `close(logChan)`,shutdown 只取消 context,避免并发 `Invoke` 触发 send on closed 
channel
   - `Shutdown()` 通过 `filterMu` 读取 `accessLogFilter`,消除与 `newFilter()` 的 data 
race
   
   新增 `TestAccessLogFilterConcurrentInvokeShutdown` 覆盖并发 `Invoke` + `Shutdown` 
场景,`go test -race -count=30 ./filter/accesslog/` 通过。



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