Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid panic in fillTables() #1365

Merged
merged 1 commit into from
Jun 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,18 @@ func (s *levelsController) fillTables(cd *compactDef) bool {
cd.top = []*table.Table{t}
left, right := cd.nextLevel.overlappingTables(levelHandlerRLocked{}, cd.thisRange)

// Sometimes below line(make([]*table.Table, right-left)) panics with error
// (runtime error: makeslice: len out of range). One of the reason for this can be when
// right < left. We don't know how to reproduce it as of now. We are just logging it so
// that we can get more context.
if right < left {
s.kv.opt.Errorf("right: %d is less than left: %d in overlappingTables for current "+
"level: %d, next level: %d, key range(%s, %s)", right, left, cd.thisLevel.level,
cd.nextLevel.level, cd.thisRange.left, cd.thisRange.right)

continue
}

cd.bot = make([]*table.Table, right-left)
copy(cd.bot, cd.nextLevel.tables[left:right])

Expand Down