Skip to content

Commit a277627

Browse files
committed
db.ScanStatistics: sanity check LimitBytesPerSecond
Informs cockroachdb/cockroach#147740
1 parent dc17527 commit a277627

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

db.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,6 +2988,10 @@ func (d *DB) ScanStatistics(
29882988
tb := tokenbucket.TokenBucket{}
29892989

29902990
if opts.LimitBytesPerSecond != 0 {
2991+
const minBytesPerSec = 100 * 1024
2992+
if opts.LimitBytesPerSecond < minBytesPerSec {
2993+
return stats, errors.Newf("pebble: ScanStatistics read bandwidth limit %d is below minimum %d", opts.LimitBytesPerSecond, minBytesPerSec)
2994+
}
29912995
// Each "token" roughly corresponds to a byte that was read.
29922996
tb.Init(tokenbucket.TokensPerSecond(opts.LimitBytesPerSecond), tokenbucket.Tokens(1024))
29932997
rateLimitFunc = func(key *InternalKey, val LazyValue) error {

0 commit comments

Comments
 (0)