Skip to content

Commit

Permalink
Merge pull request #11855 from tangcong/automated-cherry-pick-of-#118…
Browse files Browse the repository at this point in the history
…17-origin-release-3.4

Automated cherry pick of #11817 on release-3.4
  • Loading branch information
gyuho authored May 8, 2020
2 parents f1eca4e + aa75e90 commit 2333c72
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mvcc/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,18 @@ func NewStore(lg *zap.Logger, b backend.Backend, le lease.Lessor, ig ConsistentI

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)
Expand Down

0 comments on commit 2333c72

Please sign in to comment.