Skip to content

Commit

Permalink
Merge #40844
Browse files Browse the repository at this point in the history
40844: row: Add a check for integrity of neededValueColsByIdx in row fetcher r=jordanlewis a=rohany

The panic #40410 arises when a value in neededValueColsByIdx is out of
bounds of the row buffer used in the fetcher. The length of the row
buffer is equal to the number of columns in the table, so this panic is
most likely caused by the neededValueColsByIdx containing an invalid
column ID. To guard against this / have more information about debugging
this in the future, we verify during fetcher setup that all the values
in neededValueColsByIdx are within range of the table's row buffer.

Fixes #40410.

Release justification: Low risk assertion of valid behavior.

Release note: None

Co-authored-by: Rohan Yadav <[email protected]>
  • Loading branch information
craig[bot] and Rohan Yadav committed Sep 19, 2019
2 parents 83bc209 + 5bdc5c6 commit 0370137
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/sql/row/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,18 @@ func (rf *Fetcher) Init(
}
}

// In order to track #40410 more effectively, check that the contents of
// table.neededValueColsByIdx are valid.
for idx, ok := table.neededValueColsByIdx.Next(0); ok; idx, ok = table.neededValueColsByIdx.Next(idx + 1) {
if idx >= len(table.row) || idx < 0 {
return errors.AssertionFailedf(
"neededValueColsByIdx contains an invalid index. column %d requested, but table has %d columns",
idx,
len(table.row),
)
}
}

// - If there is more than one table, we have to decode the index key to
// figure out which table the row belongs to.
// - If there are interleaves, we need to read the index key in order to
Expand Down

0 comments on commit 0370137

Please sign in to comment.