Skip to content

Commit 2333c72

Browse files
authored
Merge pull request #11855 from tangcong/automated-cherry-pick-of-#11817-origin-release-3.4
Automated cherry pick of #11817 on release-3.4
2 parents f1eca4e + aa75e90 commit 2333c72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mvcc/kvstore.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ func NewStore(lg *zap.Logger, b backend.Backend, le lease.Lessor, ig ConsistentI
163163

164164
func (s *store) compactBarrier(ctx context.Context, ch chan struct{}) {
165165
if ctx == nil || ctx.Err() != nil {
166-
s.mu.Lock()
167166
select {
168167
case <-s.stopc:
169168
default:
169+
// fix deadlock in mvcc,for more information, please refer to pr 11817.
170+
// s.stopc is only updated in restore operation, which is called by apply
171+
// snapshot call, compaction and apply snapshot requests are serialized by
172+
// raft, and do not happen at the same time.
173+
s.mu.Lock()
170174
f := func(ctx context.Context) { s.compactBarrier(ctx, ch) }
171175
s.fifoSched.Schedule(f)
176+
s.mu.Unlock()
172177
}
173-
s.mu.Unlock()
174178
return
175179
}
176180
close(ch)

0 commit comments

Comments
 (0)