Skip to content

Fix Goroutine Leak in backgroundHealthCheck by Ensuring Proper Shutdown #1048

@zhengkezhou1

Description

@zhengkezhou1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions