etcdserver: take read lock when cloning store

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
release-3.5
Ted Yu 2020-05-31 09:08:26 -07:00
parent 9b6c3e3378
commit 59ec251812
1 changed files with 2 additions and 2 deletions

View File

@ -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
}