Background:
When using ch-go as the write client, we detected goroutine leaks through go.uber.org/goleak. PR: [feat] Store traces in ClickHouse based on Jaeger V2
Problem:
backgroundHealthCheck uses select to listen for the p.closeChan close signal, but p.Close() does not wait for the goroutine to exit. This may result in unterminated goroutines when main() finishes, triggering a leakcheck error.
Solution:
Use sync.WaitGroup to ensure the backgroundHealthCheck goroutine exits properly.