Merge pull request #6707 from justinsb/fix_6635

Deep-copy proto state to prevent concurrent modification
This commit is contained in:
Kubernetes Prow Robot 2019-03-30 05:21:08 -07:00 committed by GitHub
commit 33128e5fc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -159,10 +159,19 @@ func (s *state) merge(message *KVState, changes *KVState) {
s.mtx.Lock()
defer s.mtx.Unlock()
changed := mergeKVState(&s.data, message, changes)
var c KVState
if s.data.Records != nil {
c.Records = make(map[string]*KVStateRecord)
for k, v := range s.data.Records {
c.Records[k] = v
}
}
changed := mergeKVState(&c, message, changes)
if changed {
s.version++
s.data = c
}
}