AlexStocks commented on issue #3800:
URL: https://github.com/apache/dubbo-go/issues/3800#issuecomment-6718103324

   Fixed in PR #3801 (branch `fix/issue-3800-accesslog-shutdown-panic`, commit 
`8d6dc8d1`).
   
   **Chosen direction:** suggestion #2 — an `RWMutex` plus a closed flag 
guarding the send/close boundary, **keeping** `close(logChan)`. Suggestion #1 
(never close the channel) is no longer viable: #3564 was merged into `develop` 
afterwards (`d04d7751`) and its `drainLogs` dropped the `default` branch, so it 
now depends on `ok == false` from a closed channel to finish. Without the 
close, `drainLogs` would wait for the full 5s drain timeout on every shutdown.
   
   **Changes:** `logIntoChannel` takes `RLock` and returns early once closed; 
`shutdown` takes the write lock before setting the flag and closing, which 
waits for all in-flight sends. Added `filter/accesslog/shutdown_race_test.go` 
with three regression tests: post-shutdown sends, buffered logs still drainable 
after close, and 32 goroutines racing `Invoke` against `shutdown`.
   
   **Verified** on Go 1.25.0: `gofmt -l`, `go vet ./filter/accesslog/`, `go 
test ./filter/accesslog/ -count=1` and `go test -race ./filter/accesslog/ 
-count=1` all pass. As a control, reverting `filter.go` to unmodified `develop` 
makes two of the three new tests fail with `send on closed channel` (32/32 
goroutines panicking in the stress test), so the tests genuinely catch the 
regression.
   
   **Left out of scope:** `shutdown()` still closes cached file handles while 
`writeLogToFile` may be running in the drain goroutine. That path yields a 
logged write error / dropped late logs rather than a panic, and is a separate 
issue from the one tracked here.
   


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