This PR causes the db to revert to mmap(db, db.datasz) if the call to mmap(db, minsz) fails. The original error is still returned, so callers will see "mmap failure" returned from db.Update. I also wrapped this error in a new type, so that callers can check for it explicitly. This is good to have, since I imagine applications will want to panic instead of continuing to attempt more db.Update calls. Another option would be to add a PanicOnFailedMmap flag so that bolt will automatically panic under these conditions.
I'm not 100% sure that this code is safe, but I've confirmed that it resolves the segfault bug, and it appears that calls to db.View will succeed even after mmap failure.
Fixes #706.
This PR causes the db to revert to
mmap(db, db.datasz)
if the call tommap(db, minsz)
fails. The original error is still returned, so callers will see"mmap failure"
returned fromdb.Update
. I also wrapped this error in a new type, so that callers can check for it explicitly. This is good to have, since I imagine applications will want to panic instead of continuing to attempt moredb.Update
calls. Another option would be to add aPanicOnFailedMmap
flag so that bolt will automatically panic under these conditions.I'm not 100% sure that this code is safe, but I've confirmed that it resolves the segfault bug, and it appears that calls to
db.View
will succeed even after mmap failure.