0
0
Fork 0

cleaning up the wait loop

This commit is contained in:
Sreekanth Sivasankaran 2018-02-25 20:58:53 +05:30
parent 3a571ad283
commit f0a65f041d
1 changed files with 8 additions and 9 deletions

View File

@ -164,16 +164,12 @@ func notifyMergeWatchers(lastPersistedEpoch uint64,
func (s *Scorch) pausePersisterForMergerCatchUp(lastPersistedEpoch uint64, lastMergedEpoch *uint64,
persistWatchers []*epochWatcher) []*epochWatcher {
// first, let the watchers proceed if they lag behind
persistWatchers = notifyMergeWatchers(lastPersistedEpoch, persistWatchers)
OUTER:
for {
// first, let the watchers proceed if they lag behind
persistWatchers = notifyMergeWatchers(lastPersistedEpoch, persistWatchers)
// check for slow merger and pause persister until merger catch up
if lastPersistedEpoch <= *lastMergedEpoch+epochDistance {
break OUTER
}
// check for slow merger and await until the merger catch up
for lastPersistedEpoch > *lastMergedEpoch+epochDistance {
select {
case <-s.closeCh:
@ -182,6 +178,9 @@ OUTER:
persistWatchers = append(persistWatchers, ew)
*lastMergedEpoch = ew.epoch
}
// let the watchers proceed if they lag behind
persistWatchers = notifyMergeWatchers(lastPersistedEpoch, persistWatchers)
}
return persistWatchers