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 Feb 13, 2023
1 parent cae7356 commit 246c158
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 246c158

Please sign in to comment.