0
0
Fork 0

cleaning up the wait loop

This commit is contained in:
Sreekanth Sivasankaran 2018-02-24 23:53:49 +05:30 committed by GitHub
parent a8ebf2a553
commit 874829759b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 13 deletions

View File

@ -42,8 +42,7 @@ var DefaultChunkFactor uint32 = 1024
// an optimum pace so that the merger can skip
// many intermediate snapshots.
// This needs to be based on empirical data.
// With high segment count with snapshots,
// doubtful on the effectiveness of this approach.
// TODO - may need to revisit this approach/value.
var epochDistance = uint64(5)
type notificationChan chan struct{}
@ -172,19 +171,17 @@ OUTER:
persistWatchers = notifyMergeWatchers(lastPersistedEpoch, persistWatchers)
// check for slow merger and pause persister until merger catch up
if lastPersistedEpoch > *lastMergedEpoch+epochDistance {
select {
case <-s.closeCh:
break OUTER
case ew := <-s.persisterNotifier:
persistWatchers = append(persistWatchers, ew)
*lastMergedEpoch = ew.epoch
continue OUTER
}
} else {
if lastPersistedEpoch <= *lastMergedEpoch+epochDistance {
break OUTER
}
select {
case <-s.closeCh:
break OUTER
case ew := <-s.persisterNotifier:
persistWatchers = append(persistWatchers, ew)
*lastMergedEpoch = ew.epoch
}
}
return persistWatchers