This commit refactors the test suite to make it cleaner and to use the
standard testing library better. The `assert()`, `equals()`, and `ok()`
functions have been removed and some test names have been changed for
clarity.
No functionality has been changed.
InitialMmapSize is the initial mmap size of the database in bytes.
Read transaction won't block write transaction if InitialMmapSize
is large enough to handle mmap size.
Copied from https://github.com/boltdb/bolt/pull/432.
- ErrInvalid is returned when a data file is not a Bolt-formatted
database.
- ErrVersionMismatch is returned when the data file was created with a
different version of Bolt.
- ErrChecksum is returned when either meta page checksum does not match.
Also:
- Do not wrap errors from os.Stat, so that a caller could handle os.Stat
errors just like it can handle errors from os.Open that bolt.Open
might return.
- Name tests consistently, following the pattern "TestOpen_*".
- Remove deferred calls to `os.Remove(path)`.
The calls are not only unnecessary, but also in all cases `os.Remove`
returns an error that is ignored. All those calls are meant to remove
a file that was already removed by `tmpfile()`.
- Combine "bad path" tests and use filepath.Join to build the path.
This adds MmapFlags to DB.Options in case we need syscall.MAP_POPULATE
flag in Linux 2.6.23+ to do the sequential read-ahead, as discussed in [1].
---
[1]: https://github.com/coreos/etcd/issues/3786
Only grow the database size when the high watermark increases.
We also grows the database size a little bit aggressively to
save a few ftruncates.
I have tested this on various environments. The performance impact
is ignorable with 16MB over allocation. Without over allocation,
the performance might decrease 100% when each Tx.Commit needs a new
page on a very slow disk (seek time dominates the total write).
This commit fixes an issue where keys are skipped by cursors after
deletions occur in a bucket. This occurred because the cursor seeks
to the leaf page but does not check if it is empty.
Fixes#429, #450
This commit changes the maximum value size to 2GB so that tests can
run on 32-bit machines. There's really no reason to write a 2GB+
value to Bolt. It's not terribly efficient for large values.
I have been bitten by this when running a simple application on a
Raspberry Pi 2. It had 3 stores: two 512M stores and one 128M. The
application refused to start the moment the first index grew from 512M
to 1G.
Bolt is really nice but it is easy to overlook this limitation,
especially with the note about supporting stores much larger than
*physical* memory.