mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 15:51:01 +00:00
avoid out-of-bounds panic in rbf
We've seen this happen with relatively large datasets with a relatively low max-file-size. The solution we came up with was to increase the max-file-size config option, which works, but we still don't want there to be a panic if we hit this again. see https://molecula.atlassian.net/browse/FB-1381 for more information.
This commit is contained in:
parent
5b11f3b3b1
commit
a97c877f86
1 changed files with 9 additions and 1 deletions
10
rbf/db.go
10
rbf/db.go
|
|
@ -815,7 +815,15 @@ func (db *DB) writeDBPage(pgno uint32, page []byte) error {
|
|||
|
||||
func (db *DB) readDBPage(pgno uint32) ([]byte, error) {
|
||||
offset := int64(pgno) * PageSize
|
||||
return db.data[offset : offset+PageSize], nil
|
||||
|
||||
// FB-1381
|
||||
// Verify page number requested is within the current size of database.
|
||||
bound := offset + PageSize
|
||||
if sz := int64(len(db.data)); bound >= sz {
|
||||
return nil, fmt.Errorf("rbf: page read out of bounds, pgno=%d upper-bound=%d file-size=%d", pgno, bound, sz)
|
||||
}
|
||||
|
||||
return db.data[offset:bound], nil
|
||||
}
|
||||
|
||||
// readWALPageByID reads a WAL page by WAL ID.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue