UPSTREAM: 82303: GuaranteedUpdate, retry on precondition check failure if we are working with cached data
@@ -283,9 +283,22 @@ func (s *store) GuaranteedUpdate(
transformContext := authenticatedDataString(key)
for {
if err := preconditions.Check(key, origState.obj); err != nil {
+ // 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)
if err != nil {
// If our data is already up to date, return the error
