File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,9 @@ func (s *Scorch) persisterLoop() {
9090 var persistWatchers []* epochWatcher
9191 var lastPersistedEpoch , lastMergedEpoch uint64
9292 var ew * epochWatcher
93+
94+ var unpersistedCallbacks []index.BatchCallback
95+
9396 po , err := s .parsePersisterOptions ()
9497 if err != nil {
9598 s .fireAsyncError (fmt .Errorf ("persisterOptions json parsing err: %v" , err ))
@@ -149,11 +152,25 @@ OUTER:
149152 _ = ourSnapshot .DecRef ()
150153 break OUTER
151154 }
155+
156+ // save this current snapshot's persistedCallbacks, to invoke during
157+ // the retry attempt
158+ unpersistedCallbacks = append (unpersistedCallbacks , ourPersistedCallbacks ... )
159+
152160 s .fireAsyncError (fmt .Errorf ("got err persisting snapshot: %v" , err ))
153161 _ = ourSnapshot .DecRef ()
154162 atomic .AddUint64 (& s .stats .TotPersistLoopErr , 1 )
155163 continue OUTER
156164 }
165+
166+ if unpersistedCallbacks != nil {
167+ // in the event of this being a retry attempt for persisting a snapshot
168+ // that had earlier failed, prepend the persistedCallbacks associated
169+ // with earlier segment(s) to the latest persistedCallbacks
170+ ourPersistedCallbacks = append (unpersistedCallbacks , ourPersistedCallbacks ... )
171+ unpersistedCallbacks = nil
172+ }
173+
157174 for i := range ourPersistedCallbacks {
158175 ourPersistedCallbacks [i ](err )
159176 }
You can’t perform that action at this time.
0 commit comments