Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
remap old size if new mmap fails
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechampine committed Jul 18, 2017
1 parent 2f1ce7a commit 657f184
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ func (db *DB) mmap(minsz int) error {

// Memory-map the data file as a byte slice.
if err := mmap(db, size); err != nil {
// mmap failed; the system may have run out of space. Fallback to
// mapping the bare minimum needed for the current db size.
if err2 := mmap(db, db.datasz); err2 != nil {
panic(fmt.Sprintf("failed to revert db size after failed mmap: %v", err2))
}
return err
}

Expand Down

0 comments on commit 657f184

Please sign in to comment.