Skip to content

Commit

Permalink
Merge pull request #21 from databricks/out-of-bound-crash-debug
Browse files Browse the repository at this point in the history
Add logs to debug Store out-of-bound error
  • Loading branch information
hczhu-db authored Mar 20, 2024
2 parents 45d9a8f + 8d38507 commit 4ed8a45
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -3519,6 +3519,9 @@ func (r *bucketChunkReader) loadChunks(ctx context.Context, res []seriesEntry, a
} else {
buf = make([]byte, r.block.estimatedMaxChunkSize)
}
if cap(buf) < r.block.estimatedMaxChunkSize {
return errors.Errorf("chunk buffer too small, expected at least %d, got %d", r.block.estimatedMaxChunkSize, cap(buf))
}
defer r.block.chunkPool.Put(&buf)

for i, pIdx := range pIdxs {
Expand All @@ -3539,6 +3542,10 @@ func (r *bucketChunkReader) loadChunks(ctx context.Context, res []seriesEntry, a
chunkLen = int(diff)
}
}
if cap(buf) < chunkLen {
return errors.Errorf("chunk buffer too small. expected at least %d(estimatedMaxChunkSize = %d), got %d",
chunkLen, r.block.estimatedMaxChunkSize, cap(buf))
}
cb := buf[:chunkLen]
n, err = io.ReadFull(bufReader, cb)
readOffset += n
Expand Down

0 comments on commit 4ed8a45

Please sign in to comment.