From 8fa7783875248b8afb452756b6cf109300698d9b Mon Sep 17 00:00:00 2001 From: tangcong Date: Sun, 26 Apr 2020 21:05:30 +0800 Subject: [PATCH 1/2] mvcc: fix deadlock bug --- mvcc/kvstore.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mvcc/kvstore.go b/mvcc/kvstore.go index 79b7c686c..4cbff0e39 100644 --- a/mvcc/kvstore.go +++ b/mvcc/kvstore.go @@ -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() } - s.mu.Unlock() return } close(ch) From a7423f2b7b510f85ad71984029f32f47294ab1fb Mon Sep 17 00:00:00 2001 From: tangcong Date: Sun, 26 Apr 2020 21:10:30 +0800 Subject: [PATCH 2/2] CHANGELOG: update for 11817 --- CHANGELOG-3.5.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-3.5.md b/CHANGELOG-3.5.md index b258de30c..b2c8dc0cb 100644 --- a/CHANGELOG-3.5.md +++ b/CHANGELOG-3.5.md @@ -104,6 +104,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`