From 59ec251812b19674184643c55fa4d4cab7ba1d73 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Sun, 31 May 2020 09:08:26 -0700 Subject: [PATCH] etcdserver: take read lock when cloning store Signed-off-by: Ted Yu --- etcdserver/api/v2store/store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etcdserver/api/v2store/store.go b/etcdserver/api/v2store/store.go index 9812ebd41ad..5a975cb958a 100644 --- a/etcdserver/api/v2store/store.go +++ b/etcdserver/api/v2store/store.go @@ -747,7 +747,7 @@ func (s *store) SaveNoCopy() ([]byte, error) { } func (s *store) Clone() Store { - s.worldLock.Lock() + s.worldLock.RLock() clonedStore := newStore() clonedStore.CurrentIndex = s.CurrentIndex @@ -756,7 +756,7 @@ func (s *store) Clone() Store { clonedStore.Stats = s.Stats.clone() clonedStore.CurrentVersion = s.CurrentVersion - s.worldLock.Unlock() + s.worldLock.RUnlock() return clonedStore }