mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
mvcc/kvstore:when the number key-value is greater than one million, compact take too long and blocks other requests
This commit is contained in:
parent
bdc9bc1d81
commit
89b10cf967
@ -271,15 +271,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
|
||||
@ -288,8 +288,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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user