Skip to content

Commit

Permalink
Merge pull request #11959 from tedyu/store-clone-rd-lock
Browse files Browse the repository at this point in the history
etcdserver: take read lock when cloning store
  • Loading branch information
gyuho authored Jun 3, 2020
2 parents a09533d + 59ec251 commit 62f1fef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions etcdserver/api/v2store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func (s *store) SaveNoCopy() ([]byte, error) {
}

func (s *store) Clone() Store {
s.worldLock.Lock()
s.worldLock.RLock()

clonedStore := newStore()
clonedStore.CurrentIndex = s.CurrentIndex
Expand All @@ -764,7 +764,7 @@ func (s *store) Clone() Store {
clonedStore.Stats = s.Stats.clone()
clonedStore.CurrentVersion = s.CurrentVersion

s.worldLock.Unlock()
s.worldLock.RUnlock()
return clonedStore
}

Expand Down

0 comments on commit 62f1fef

Please sign in to comment.