From e7127b3e1f129306938b94aa648f4486309ccd54 Mon Sep 17 00:00:00 2001 From: chengshiwen Date: Thu, 29 Aug 2024 23:23:15 +0800 Subject: [PATCH] fix race condition in meta client --- services/meta/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/meta/client.go b/services/meta/client.go index 543eb39..743dc09 100644 --- a/services/meta/client.go +++ b/services/meta/client.go @@ -153,7 +153,11 @@ func (c *Client) Close() error { } // NodeID returns the client's node ID. -func (c *Client) NodeID() uint64 { return c.nodeID } +func (c *Client) NodeID() uint64 { + c.mu.RLock() + defer c.mu.RUnlock() + return c.nodeID +} // SetMetaServers updates the meta servers on the client. func (c *Client) SetMetaServers(a []string) {