Commit Graph

128 Commits (b9869663616be4ac56a1222841265dc0b696c253)

Author SHA1 Message Date
Ben Johnson a03d52a9dd Add docs for dependent transactions.
This commit adds documentation to clarify that read-only and read-write
transactions should not be mixed in the same goroutine as it can cause
deadlocks during remapping.

See: https://github.com/boltdb/bolt/issues/378
2015-05-21 09:50:13 -06:00
Ben Johnson e929eba364 Wait for pending tx on close.
This commit fixes the DB.Close() function so that it waits for any
open transactions to finish before closing.
2015-05-20 16:10:07 -06:00
Ben Johnson d4363a9208 Merge branch 'ro' 2015-05-18 13:45:09 -06:00
Ben Johnson df52bd0803 Add test case inline documentation. 2015-05-18 13:45:02 -06:00
sasha-s aa13f7f94f make ignoring Truncate() explicit
https://github.com/boltdb/bolt/pull/371#issuecomment-103176330
2015-05-18 12:00:40 -07:00
sasha-s fda75748b5 use a shared lock in read-only mode
https://github.com/boltdb/bolt/pull/371#issuecomment-103119486
2015-05-18 11:07:19 -07:00
Ben Johnson a450f843ee Change min mmap size from 1MB to 32KB.
This commit adjusts the minimum mmap size from 1MB to 32KB. The
previous limit was arbitrary and causes wasted space for very small
databases.

Thanks to @mcuadros for submitting the original pull request:

  https://github.com/boltdb/bolt/pull/351
2015-05-18 10:37:47 -06:00
sasha-s 019bf5b010 open read-only databases in read-only mode 2015-05-14 15:43:13 -07:00
Ben Johnson e5aaa976ba Add DB.Sync().
This commit adds DB.Sync() for users who set DB.NoSync to true.
2015-05-08 13:11:15 -06:00
Ben Johnson b107b35f19 Add DB.NoGrowSync flag.
This commit adds the DB.NoGrowSync flag to optionally revert mmap()
calls to how they were implemented before the ext3/ext4 fix. When
NoGrowSync is true, remapping the data file will not force the file
system to resize it immediately. This works for non-ext3/4 file
systems.

The default value of NoGrowSync is false so it is still safe for
ext3/ext4 file systems by default.

See also: https://github.com/boltdb/bolt/issues/284
2015-05-06 09:23:32 -06:00
funkygao 6d043164a9 add comment: db.dataref is readonly 2015-03-25 22:05:58 +08:00
funkygao 20852b29c4 fix comment bug: minium db mmapSize is 1MB instead of 4MB 2015-03-25 22:04:41 +08:00
Tommi Virtanen adbb1a19c1 Add transaction batching
DB.Batch makes it easy to make lots of small transactions with
significantly better performance. Batch combines multiple concurrent
Update calls into a single disk transaction, managing errors smartly.
2015-02-18 12:26:45 -08:00
Ben Johnson e7f5c931e2 Fix large mmap resize.
This commit fixes an issue where large databases were being resized to
larger sizes on every open.
2015-02-16 15:23:48 -07:00
Ben Johnson ac1149a3f5 Persist sequence-only changes.
This commit fixes a bug where only calling NextSequence() on a Bucket does not cause the Bucket to be
peristed. The simple fix is to simply materialize the root node so that the bucket is flushed out
during commit.

Thanks to Matthew Dawson (@MJDSys) for reporting.

https://github.com/boltdb/bolt/issues/296
2015-02-02 08:27:34 -07:00
Ben Johnson b4d00c394a Expand assertion statements.
This commit expands calls to _assert() that use variadic arguments. These calls require conversion to interface{} so there
was a large number of calls to Go's internal convT2E() function. In some profiling this was taking over 20% of total runtime.
I don't remember seeing this before Go 1.4 so perhaps something has changed.
2015-01-30 14:15:49 -05:00
Ben Johnson 338d8e78e2 Fix max mmap check for 32-bit arch. 2015-01-28 16:27:06 -05:00
Ben Johnson dacc1873d1 Fix mmap step & max size check.
This commit adds fixes suggested by @tv42 for the mmap step fix in 834b38e:

* Check max size before calculating the new the mmap size.
* Fix mmap step loop to go to 1GB instead of 512MB.
2015-01-28 13:03:30 -05:00
Ben Johnson 834b38e3e7 Fix mmap resize calculation.
This commit fixes an issue where the database would grow whenever it was opened. This was caused by
a recent change that performed a truncation when the database grew. Now there are fixed growth sizes
for the database (1MB, 2MB, 4MB, 8MB, etc) up to 1GB and then the database will grow by 1GB when it
resizes.

See also: 6bb25854a1
2015-01-28 11:29:27 -05:00
pmcgrath 2110587fdd Removed redundant duplicate line of code 2015-01-22 12:15:40 +00:00
Ben Johnson 8374d6adc5 Add check for max mmap size.
The max mmap size was previous unchecked which resulted in a panic once
the maximum size was reached. This commit adds a check for the max size
when re-mapping and returns an error if the new map will exceed the size.

Thanks to Tamás Gulácsi for testing out the change on i386.
2015-01-12 08:06:42 -07:00
Josh Rickmar a2cbaa05f9 Fix bolt on OpenBSD.
OpenBSD does not include a UBC kernel and writes must be synchronized
with the msync(2) syscall.  In addition, the NoSync field of the DB
struct should be ignored on OpenBSD, since unlike other platforms,
missing msyncs will result in data corruption.

Depends on PR #258.

Fixes #257.
2014-09-18 18:14:50 -05:00
Ben Johnson ba6badc57f Move tests to a test package. 2014-07-26 15:11:47 -06:00
Ben Johnson c3400efefd Change fill percent to be per-bucket.
This commit moves the DB.FillPercent field to Bucket.FillPercent. This
allows the fill percentage to be specified per-bucket, per-tx. This
value is not persisted and should be set whenever using it.
2014-07-24 10:36:09 -06:00
Ben Johnson 048d3f19b2 Add DB.NoSync option for bulk loading.
This commit adds the DB.NoSync flag to skip fsync() calls on each commit. This should only
be used for bulk loading as it can corrupt your database in the event of a system failure.

Initial tests show it can provide a 2x speed up for sequential inserts.
2014-07-15 07:37:46 -06:00
Ben Johnson ac4838472d Recover from panics appropriately.
This commit adds a defer handler to ensure that transactions are always closed out - even
in the event of a panic within user code. It's recommended that applications always fail
in the event of a panic but some packages such as net/http will automatically recover
which is a problem (IHMO).
2014-07-11 09:54:10 -06:00
Ben Johnson cc8004c980 Merge branch 'master' of https://github.com/boltdb/bolt into free-cache 2014-07-10 14:00:32 -06:00
Ben Johnson e903703e61 Fix Windows mmap sizing.
This commit fixes an issue on Windows where the database was doubling
when it was re-opened. This occurred because Windows has to truncate the
file to the mmap size and the mmap resizing code was doubling the size
whenever the DB size was at the next threshold. This has been changed so
that the DB size will double only when the DB size is above the next
threshold.
2014-07-10 07:11:01 -06:00
Ben Johnson def455554b Add freelist cache.
This commit adds a cache to the freelist which combines the available free pages and pending free pages in
a single map. This was added to improve performance where freelist.isFree() was consuming 70% of CPU time
for large freelists.
2014-06-30 08:01:41 -06:00
Martin Kobetic 8c386e72f3 Copy the free pages stats from the receiver 2014-06-27 17:38:06 +00:00
Ben Johnson d1a77a9c82 Minor fix. 2014-06-24 11:58:46 -06:00
Martin Kobetic bae0fbd290 review tweaks 2014-06-24 17:54:40 +00:00
Martin Kobetic ba79a0a355 drop the *s guard 2014-06-24 17:40:53 +00:00
Martin Kobetic 8dd18bd620 review tweaks 2014-06-24 17:19:50 +00:00
Martin Kobetic 32e22b3bb6 add some guards for nil pointers 2014-06-24 15:32:04 +00:00
Martin Kobetic bbee09da30 copy receiver stats in Stats.Sub() 2014-06-24 15:32:04 +00:00
Ben Johnson 642b104396 Add DefaultOptions variable.
This commit adds an explicit DefaultOptions variable for additional documentation.
Open() can still be passed a nil options which will cause options to be change to
the DefaultOptions variable. This change also allows options to be set globally for
an application if more than one database is being opened in a process.

This commit also moves all errors to errors.go so that the godoc groups them together.
2014-06-22 12:44:20 -06:00
Ben Johnson 00ee0da528 Add Open() options, flock timeout.
This commit changes Open() to provide an additional Options argument. The options
argument currently only has a Timeout which will cause the Open() to return
ErrTimeout if a file lock cannot be obtained in time.

Fixes #207.
2014-06-21 14:44:28 -06:00
Martin Kobetic 571f201672 split the freelist page count stats to free and pending 2014-06-20 14:53:25 +00:00
Ben Johnson b1dbd35da1 Fix merge-split regression.
This commit reverts merge-split and fixes the node.split() to do a multi-page split. This issue
caused problems with bulk loading because it would split into a small page and a very large page.
The very large page, in turn, would be an arbitrary size so when it was freed later it would be
difficult to reuse and would cause serious fragmentation issues.
2014-06-18 16:16:58 -06:00
Martin Kobetic 8a386756df fix up freelist stats naming and add FreeAlloc 2014-06-18 18:10:42 +00:00
Martin Kobetic 4918ce8301 drop mergeStats and move freelist stats update to Tx 2014-06-17 19:30:10 +00:00
Martin Kobetic c105316292 add freelist stats to db stats 2014-06-17 18:40:56 +00:00
Ben Johnson defdb743cd Fix deadlock on remmap.
This commit fixes a deadlock situation that can occur when Bolt's database size crosses a threshold
and requires remapping the mmap.
2014-06-13 12:07:37 -06:00
Ben Johnson 1c97a490dd Add Windows support.
This commit adds Windows support to Bolt. Windows memory maps return an address instead of a byte
slice so the DB.data field had to be refactored to be a pointer to a large byte array.
2014-06-12 09:23:30 -06:00
Ben Johnson c2577db1c2 Add Windows support. 2014-06-11 11:11:21 -06:00
Ben Johnson b789691976 Add streaming check.
This commit changes Tx.Check() to return a channel through which check errors are returned. This allows
errors to be found before checking the entire data file.
2014-05-28 10:31:22 -06:00
Ben Johnson 92a9f2e200 Remove DB.Check(). Allow read-only Tx.Check().
This commit removes the DB.Check() function and instead makes the user decide
whether a transaction should be writable or read-only. Tx.Check() is not safe
to use concurrently on a read-only transaction, however, it significantly
improves the performance of it.
2014-05-27 11:31:55 -06:00
Ben Johnson 7432bc341f Merge pull request #169 from benbjohnson/allocation
Fix freelist allocation direction.
2014-05-21 13:46:12 -06:00
Martin Kobetic 519d65228e move Copy and CopyFile from DB to Tx 2014-05-21 15:08:37 +00:00