From 86ce681443e0a04dc3a85ef68c0f1334e9934ccd Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Sat, 18 Jan 2025 19:29:22 +0000 Subject: [PATCH] close client and metrics listeners firstly when shutting down etcd Signed-off-by: Benjamin Wang --- server/embed/etcd.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/embed/etcd.go b/server/embed/etcd.go index fe2450401de..5f8f7e33d96 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -411,6 +411,16 @@ func (e *Etcd) Close() { close(e.stopc) }) + for i := range e.Clients { + if e.Clients[i] != nil { + e.Clients[i].Close() + } + } + + for i := range e.metricsListeners { + e.metricsListeners[i].Close() + } + // close client requests with request timeout timeout := 2 * time.Second if e.Server != nil { @@ -428,16 +438,6 @@ func (e *Etcd) Close() { sctx.cancel() } - for i := range e.Clients { - if e.Clients[i] != nil { - e.Clients[i].Close() - } - } - - for i := range e.metricsListeners { - e.metricsListeners[i].Close() - } - // shutdown tracing exporter if e.tracingExporterShutdown != nil { e.tracingExporterShutdown()