man-mu opened a new pull request, #3701:
URL: https://github.com/apache/dubbo-go/pull/3701

   Fixes #3700
   
   ### Description
   The CI `-race` job intermittently fails 
`TestAccessLogFilterGoroutineShutdown`
   with `"3" is not greater than "3"` (memory_leak_test.go:64). The test 
asserted
   the `processLogs` goroutine lifecycle by comparing global 
`runtime.NumGoroutine()`
   counts around a fixed 100ms sleep — under `-race`, other background 
goroutines
   (log writers, test framework) naturally exit during that window and cancel 
out
   the +1, so the assertion is timing- and environment-dependent.
   
   Beyond the test, `Shutdown()` never waited for `processLogs` to exit: it
   cancelled the context and closed `logChan`, then immediately closed cached
   file handles while `drainLogs()` could still be running for up to 5s. Callers
   could not observe when shutdown actually completed.
   
   ### Changes
   - Add a private `done` channel to `Filter`, closed when `processLogs` exits
     (deferred close registered first, so it runs after `drainLogs` completes)
   - `Shutdown()` now waits for `processLogs` to exit (up to 6s, covering the 5s
     drain timeout) before closing cached file handles
   - Drop the unsynchronized `accessLogFilter == nil` check in `newFilter()` and
     rely solely on `sync.Once`, removing a data race on the package-level
     variable under concurrent calls
   - Rewrite `TestAccessLogFilterGoroutineShutdown` to assert on the 
deterministic
     `done` signal instead of global goroutine counts
   
   ### Test
   `TestAccessLogFilterGoroutineShutdown` in `memory_leak_test.go` now verifies:
   - the `processLogs` goroutine is running after `newFilter()` (`done` not yet 
closed)
   - `Shutdown()` makes it exit deterministically (`done` closed within 5s)
   
   ### Validation
   - `make fmt` — no changes, the code already conforms to the repo format rules
   - `make test` — full repository unit tests pass, 0 failures
   - `go test -race -count=50 -run TestAccessLogFilter ./filter/accesslog/` — 
passes consistently
   - `go test -race -count=30 ./filter/accesslog/` — passes (Linux-only fd 
tests skipped on macOS)
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] I have run `make fmt` to format my code
   - [x] I have run `make test` to run local tests
   - [x] I have added tests that prove my fix is effective or that my feature 
works


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