Skip to content

Commit

Permalink
Fix potential deadlock in levelsController compaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronan Harmegnies committed Jul 20, 2022
1 parent 7d159dd commit 596a5ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,15 @@ func (s *levelsController) addSplits(cd *compactDef) {

func (cd *compactDef) lockLevels() {
cd.thisLevel.RLock()
cd.nextLevel.RLock()
if cd.thisLevel.level != cd.nextLevel.level {
cd.nextLevel.RLock()
}
}

func (cd *compactDef) unlockLevels() {
cd.nextLevel.RUnlock()
if cd.thisLevel.level != cd.nextLevel.level {
cd.nextLevel.RUnlock()
}
cd.thisLevel.RUnlock()
}

Expand Down

0 comments on commit 596a5ca

Please sign in to comment.