Aias00 opened a new pull request, #993:
URL: https://github.com/apache/dubbo-go-pixiu/pull/993
## Summary
Fixes #989 Issue 3 (listener/shutdown path): The original implementation
called `os.Exit(0)` from worker goroutines during shutdown, which is too
aggressive.
### Original Problems
- `os.Exit(0)` was called in per-listener worker goroutines on shutdown error
- `os.Exit(0)` was called in timeout handler (`time.AfterFunc`)
- Process always exited with success code (0), even when shutdown errors
occurred
- One listener shutdown failure would immediately exit the process while
other cleanup was still in progress
### Why this matters
These are operational stability issues:
- Configuration mistakes or transient dependency failures can terminate the
whole process
- One listener shutdown failure can immediately exit the process while other
cleanup is still in progress
- Metrics/tracing/log flush may not complete
- Makes the system harder to embed, test, and recover
### Changes
- Remove `os.Exit(0)` calls from per-listener worker goroutines
- Remove `os.Exit(0)` from timeout handler (`time.AfterFunc`)
- Collect shutdown errors in a buffered channel instead of immediate exit
- Wait for all shutdowns to complete or timeout before proceeding
- Exit with appropriate code: 0 for success, 1 if errors occurred
- Add unit tests for error collection, timeout handling, and WaitGroup
behavior
### Note on WaitGroup
`listener.ShutDown()` methods internally call `wg.Done()`, so we do not add
`defer wg.Done()` in the worker goroutine to avoid double `Done()` calls which
would panic with negative WaitGroup counter.
## Test Plan
- Added `pkg/server/listener_manager_test.go` with tests covering:
- WaitGroup double-Done panic behavior
- Shutdown error collection pattern
- Shutdown timeout handling pattern
- Labeled break pattern for draining channels
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]