Always flush when timer goes off

This commit is contained in:
Aayush Rajasekaran 2021-06-22 19:16:36 -04:00
parent 9e4875f210
commit 6ca2a14819

View File

@ -108,7 +108,7 @@ func (b *CommitBatcher) run() {
} }
lastMsg = nil lastMsg = nil
var sendAboveMax, sendAboveMin bool var sendAboveMax bool
select { select {
case <-b.stop: case <-b.stop:
close(b.stopped) close(b.stopped)
@ -116,13 +116,13 @@ func (b *CommitBatcher) run() {
case <-b.notify: case <-b.notify:
sendAboveMax = true sendAboveMax = true
case <-b.batchWait(cfg.CommitBatchWait, cfg.CommitBatchSlack): case <-b.batchWait(cfg.CommitBatchWait, cfg.CommitBatchSlack):
sendAboveMin = true // do nothing
case fr := <-b.force: // user triggered case fr := <-b.force: // user triggered
forceRes = fr forceRes = fr
} }
var err error var err error
lastMsg, err = b.maybeStartBatch(sendAboveMax, sendAboveMin) lastMsg, err = b.maybeStartBatch(sendAboveMax)
if err != nil { if err != nil {
log.Warnw("CommitBatcher processBatch error", "error", err) log.Warnw("CommitBatcher processBatch error", "error", err)
} }
@ -170,7 +170,7 @@ func (b *CommitBatcher) batchWait(maxWait, slack time.Duration) <-chan time.Time
return time.After(wait) return time.After(wait)
} }
func (b *CommitBatcher) maybeStartBatch(notif, after bool) ([]sealiface.CommitBatchRes, error) { func (b *CommitBatcher) maybeStartBatch(notif bool) ([]sealiface.CommitBatchRes, error) {
b.lk.Lock() b.lk.Lock()
defer b.lk.Unlock() defer b.lk.Unlock()
@ -188,10 +188,6 @@ func (b *CommitBatcher) maybeStartBatch(notif, after bool) ([]sealiface.CommitBa
return nil, nil return nil, nil
} }
if after && total < cfg.MinCommitBatch {
return nil, nil
}
var res []sealiface.CommitBatchRes var res []sealiface.CommitBatchRes
if total < cfg.MinCommitBatch || total < miner5.MinAggregatedSectors { if total < cfg.MinCommitBatch || total < miner5.MinAggregatedSectors {