Skip to content

Commit

Permalink
fix(levelHandler): use lock for levelHandler sort tables instead of r…
Browse files Browse the repository at this point in the history
…lock (#2034)

Co-authored-by: guangzhixu <guangzhixu@deepglint.com>
  • Loading branch information
xgzlucario and satoshi-099 committed Dec 18, 2023
1 parent 09b73f7 commit 589c786
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions level_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func (s *levelHandler) addTable(t *table.Table) {
// sortTables sorts tables of levelHandler based on table.Smallest.
// Normally it should be called after all addTable calls.
func (s *levelHandler) sortTables() {
s.RLock()
defer s.RUnlock()
s.Lock()
defer s.Unlock()

sort.Slice(s.tables, func(i, j int) bool {
return y.CompareKeys(s.tables[i].Smallest(), s.tables[j].Smallest()) < 0
Expand Down

0 comments on commit 589c786

Please sign in to comment.