mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Fix size/PageSize calculation to be int64.
This commit is contained in:
parent
3b8ce696bd
commit
fe7c97afa0
1 changed files with 5 additions and 5 deletions
10
rbf/db.go
10
rbf/db.go
|
|
@ -237,11 +237,11 @@ func (db *DB) openWAL() (err error) {
|
|||
}
|
||||
|
||||
if fileSize != int64(pageN*PageSize) {
|
||||
if err := db.walFile.Truncate(int64(pageN * PageSize)); err != nil {
|
||||
if err := db.walFile.Truncate(int64(pageN) * PageSize); err != nil {
|
||||
return fmt.Errorf("wal truncate: %w", err)
|
||||
}
|
||||
}
|
||||
if _, err := db.walFile.Seek(int64(pageN*PageSize), io.SeekStart); err != nil {
|
||||
if _, err := db.walFile.Seek(int64(pageN)*PageSize, io.SeekStart); err != nil {
|
||||
return fmt.Errorf("wal seek: %w", err)
|
||||
}
|
||||
db.walPageN = pageN
|
||||
|
|
@ -414,7 +414,7 @@ func (db *DB) checkpoint() (err error) {
|
|||
// Truncate data file if it has shrunk.
|
||||
if fi, err := db.file.Stat(); err != nil {
|
||||
db.logger.Errorf("stat db file: %w", err)
|
||||
} else if sz := int64(pageN * PageSize); sz > 0 && fi.Size() > sz {
|
||||
} else if sz := int64(pageN) * PageSize; sz > 0 && fi.Size() > sz {
|
||||
if err := db.file.Truncate(sz); err != nil {
|
||||
db.logger.Errorf("truncate db file: %w", err)
|
||||
}
|
||||
|
|
@ -571,7 +571,7 @@ func (db *DB) WALSize() int64 {
|
|||
}
|
||||
|
||||
func (db *DB) walSize() int64 {
|
||||
return int64(db.walPageN * PageSize)
|
||||
return int64(db.walPageN) * PageSize
|
||||
}
|
||||
|
||||
// init initializes a new database file.
|
||||
|
|
@ -649,7 +649,7 @@ func (db *DB) Begin(writable bool) (_ *Tx, err error) {
|
|||
// Wait for WAL size to be below threshold, if we're going to write.
|
||||
// Reads don't care.
|
||||
if writable {
|
||||
for int64(db.walPageN*PageSize) > db.cfg.MaxWALCheckpointSize {
|
||||
for int64(db.walPageN)*PageSize > db.cfg.MaxWALCheckpointSize {
|
||||
if db.isDead != nil {
|
||||
err := db.isDead
|
||||
cleanup()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue