mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #11817 from tangcong/fix-mvcc-deadlock-bug
mvcc: fix a deadlock bug in mvcc
This commit is contained in:
commit
d472f67c77
@ -105,6 +105,7 @@ Note that any `etcd_debugging_*` metrics are experimental and subject to change.
|
||||
- Improve [count-only range performance](https://github.com/etcd-io/etcd/pull/11771).
|
||||
- Remove [redundant storage restore operation to shorten the startup time](https://github.com/etcd-io/etcd/pull/11779).
|
||||
- With 40 million key test data,it can shorten the startup time from 5 min to 2.5 min.
|
||||
- [Fix deadlock bug in mvcc](https://github.com/etcd-io/etcd/pull/11817).
|
||||
|
||||
### Package `embed`
|
||||
|
||||
|
@ -145,14 +145,18 @@ func NewStore(lg *zap.Logger, b backend.Backend, le lease.Lessor, ci cindex.Cons
|
||||
|
||||
func (s *store) compactBarrier(ctx context.Context, ch chan struct{}) {
|
||||
if ctx == nil || ctx.Err() != nil {
|
||||
s.mu.Lock()
|
||||
select {
|
||||
case <-s.stopc:
|
||||
default:
|
||||
// fix deadlock in mvcc,for more information, please refer to pr 11817.
|
||||
// s.stopc is only updated in restore operation, which is called by apply
|
||||
// snapshot call, compaction and apply snapshot requests are serialized by
|
||||
// raft, and do not happen at the same time.
|
||||
s.mu.Lock()
|
||||
f := func(ctx context.Context) { s.compactBarrier(ctx, ch) }
|
||||
s.fifoSched.Schedule(f)
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
return
|
||||
}
|
||||
close(ch)
|
||||
|
Loading…
x
Reference in New Issue
Block a user