Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix][prometheusexporter] Race condition between start and shutdown (o…
…pen-telemetry#36164) #### Description Adjusted the Start and Shutdown sequence of the prometheusexporter to prevent a race condition causing the `close tcp 127.0.0.1:8999: use of closed network connection` error as observed in open-telemetry#36139. The behaviour was changed in the following ways: - If an error occurs during the creation of the server, close the listener immediately, leaving shutdown a noop - Since `srv.Shutdown` will close all open listeners, the explicit call to `ln.Close` in the shutdown routine was removed #### Link to tracking issue Fixes open-telemetry#36139 #### Testing Unit testing, I temporarily increased the number of iterations on `TestPrometheusExporter` to 2000. The error did no longer occur. However sporadically another error occured: ``` === RUN TestPrometheusExporter prometheus_test.go:103: Error Trace: C:/development/code/opentelemetry-collector-contrib/exporter/prometheusexporter/prometheus_test.go:84 Error: Received unexpected error: listen tcp 127.0.0.1:8999: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted. Test: TestPrometheusExporter --- FAIL: TestPrometheusExporter (1.16s) ``` I assume that this is because the OS (in my case Windows) won't always close the underlying sockets immediately, blocking it for some time afterwards. I'm not sure there is anything we can do about that. --------- Signed-off-by: Argannor <arga@argannor.com>
- Loading branch information