Skip to content

Commit

Permalink
Fix potential deadlock in levelsController compaction dgraph-io#1795
Browse files Browse the repository at this point in the history
Signed-off-by: thomassong <thomassong2012@gmail.com>
  • Loading branch information
mYmNeo committed Jan 17, 2023
1 parent 7c7dc31 commit d97b99c
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 @@ -777,11 +777,15 @@ type compactDef struct {

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 d97b99c

Please sign in to comment.