Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
respond to PR feedback
Signed-off-by: Matthew Sainsbury <[email protected]>
  • Loading branch information
mattsains committed Apr 25, 2025
commit 63bfedcd051d1fffd45159d3d3cdc17a8ee11577
2 changes: 1 addition & 1 deletion bolt_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func mmap(db *DB, sz int) error {
var sizelo, sizehi uint32

if !db.readOnly {
if db.MaxSize != 0 && sz > db.MaxSize {
if db.MaxSize > 0 && sz > db.MaxSize {
// The max size only limits future writes; however, we don’t block opening
// and mapping the database if it already exceeds the limit.
fileSize, err := db.fileSize()
Expand Down
6 changes: 3 additions & 3 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type DB struct {
// MaxSize is the maximum size (in bytes) allowed for the data file.
// If a caller's attempt to add data results in the need to grow
// the data file, an error will be returned and the data file will not grow.
// 0 means no limit.
// <=0 means no limit.
MaxSize int

// Mlock locks database file in memory when set to true.
Expand Down Expand Up @@ -1209,7 +1209,7 @@ func (db *DB) grow(sz int) error {
sz += db.AllocSize
}

if !db.readOnly && db.MaxSize != 0 && sz > db.MaxSize {
if !db.readOnly && db.MaxSize > 0 && sz > db.MaxSize {
lg.Errorf("[GOOS: %s, GOARCH: %s] maximum db size reached, size: %d, db.MaxSize: %d", runtime.GOOS, runtime.GOARCH, sz, db.MaxSize)
return berrors.ErrMaxSizeReached
}
Expand Down Expand Up @@ -1336,7 +1336,7 @@ type Options struct {
// PageSize overrides the default OS page size.
PageSize int

// MaxSize sets the maximum size of the data file. 0 means no maximum.
// MaxSize sets the maximum size of the data file. <=0 means no maximum.
MaxSize int

// NoSync sets the initial value of DB.NoSync. Normally this can just be
Expand Down