in GuaranteedUpdate, retry on precondition check failure if we are working with cached data

This commit is contained in:
Haowei Cai 2019-09-03 17:26:39 -07:00
parent 2670651a3c
commit 88f0be6e59

View File

@ -274,7 +274,20 @@ func (s *store) GuaranteedUpdate(
transformContext := authenticatedDataString(key)
for {
if err := preconditions.Check(key, origState.obj); err != nil {
return err
// If our data is already up to date, return the error
if !mustCheckData {
return err
}
// It's possible we were working with stale data
// Actually fetch
origState, err = getCurrentState()
if err != nil {
return err
}
mustCheckData = false
// Retry
continue
}
ret, ttl, err := s.updateState(origState, tryUpdate)