Skip to content

Commit

Permalink
mvcc/kvstore:when the number key-value is greater than one million, c…
Browse files Browse the repository at this point in the history
…ompact take too long and blocks other requests
  • Loading branch information
shenjiangc committed Nov 5, 2019
1 parent 9177098 commit 72cc5dc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mvcc/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ func (s *store) updateCompactRev(rev int64) (<-chan struct{}, error) {
}

func (s *store) compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, error) {
start := time.Now()
keep := s.kvindex.Compact(rev)
trace.Step("compact in-memory index tree")
ch := make(chan struct{})
var j = func(ctx context.Context) {
if ctx.Err() != nil {
s.compactBarrier(ctx, ch)
return
}
start := time.Now()
keep := s.kvindex.Compact(rev)
indexCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))
if !s.scheduleCompaction(rev, keep) {
s.compactBarrier(nil, ch)
return
Expand All @@ -289,8 +289,6 @@ func (s *store) compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, err
}

s.fifoSched.Schedule(j)

indexCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))
trace.Step("schedule compaction")
return ch, nil
}
Expand Down

0 comments on commit 72cc5dc

Please sign in to comment.