AlexStocks commented on code in PR #3701:
URL: https://github.com/apache/dubbo-go/pull/3701#discussion_r3849482898


##########
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:
   [P1] 首次初始化的 data race 仍然存在
   
   `Shutdown()` 虽然在读取 `accessLogFilter` 时持有 `filterMu`,但 `newFilter()` 在 
`once.Do` 内对同一变量的赋值没有持这把锁,因此锁没有建立任何 happens-before。当前 Head 上,我让首次 `newFilter()` 
与 `Shutdown()` 从同一 barrier 并发启动,执行 `go test -race` 后稳定报告 `filter.go:108` 的写与 
`filter.go:406` 的读竞态,并继续报告 `Shutdown()` 访问尚在构造中的 `Filter` 字段。新增的 
`TestAccessLogFilterConcurrentInvokeShutdown` 先顺序调用 
`newFilter()`,所以不会覆盖首次初始化交错。在隔离对照中仅让 `newFilter()` 也在同一 `filterMu` 下完成初始化和返回,同一 
1000 轮探针通过。建议让读写双方使用同一个同步域(或原子指针/统一 accessor),并把“首次 newFilter 与 Shutdown 并发”加入 
`-race` 回归测试。



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