1041 Commits

Author SHA1 Message Date
Anthony Romano
1ab9756653 fix overflow breaking 32-bit test builds 2017-08-10 23:36:52 -07:00
Pavel Borzenkov
6336a429d1 Fix deletion of non-existing keys
Doc for Bucket.Delete says that a Delete() on non-existing key is a
no-op. Right now it tries to delete the next key returned by the
cursor. Fix this by checking for key equivalence before deletion.

 Fixes #349

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2017-08-10 23:07:50 -07:00
Pavel Borzenkov
3c6c3ac0a2 Add a test for deletion of non-existing key
As of now the test fails and tries to delete the next key returned by
the cursor, which happens to be a nested bucket. That's why Delete is
fails.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2017-08-10 23:07:50 -07:00
dogben
ef8e711cfb Set FillPercent=1.0 in 'bolt compact'.
By default, pages are split when they reach half full. For 'bolt compact' we want to fill the entire page for maximum compaction.
2017-08-10 22:58:57 -07:00
Vladimir Stefanovic
e264e743a9 Add support for mips, mips64 2017-08-10 22:49:48 -07:00
Sokolov Yura aka funny_falcon
ec37ce8e9b do not read freelist if database opened readonly 2017-08-10 22:30:40 -07:00
Anthony Romano
d3d8bbd794 pass gofmt 2017-08-10 22:07:25 -07:00
Anthony Romano
32c9f9e929 pass unused 2017-08-10 22:07:25 -07:00
Anthony Romano
e5514a24a6 pass gosimple 2017-08-10 22:07:25 -07:00
Anthony Romano
89b9a2c19e make fmt
* gosimple
* unused
* gofmt
2017-08-10 22:07:25 -07:00
Christian Mauduit
319a33c534 Fix issue #543 'bolt bench crashes'
Added a test to check that bucket is actually non-nil before getting a
cursor on it. This happens when querying non-bucket entries, the
Bucket() method does not return explicit errors, so we can guess it's
probably because it's a key of the wrong type (ie: not leaf). No clear
idea wether the results in the case described '-read-mode=seq
-write-mode=rnd-nest' really do make sense, it looks like read are
zero whatsoever.
2017-08-10 21:14:06 -07:00
Anthony Romano
012f88489b add PageSize to Option struct
Configure the db page size at runtime. Makes cross-arch debugging a bit easier.
2017-08-10 20:46:08 -07:00
Anthony Romano
78ca4fde00 get rid of os.Getpagesize() calls where appropriate 2017-08-10 20:46:08 -07:00
Anthony Romano
12923fe56c Merge pull request #12 from heyitsanthony/skip-freelist-overflow
freelist: read all free pages on count overflow
v1.3.1-coreos.0
2017-08-10 14:28:08 -07:00
Anthony Romano
b219ffc6cc Merge pull request #10 from heyitsanthony/fix-freepage-test
fix NoSyncFreelist reachability checking
2017-08-09 08:48:36 -07:00
Anthony Romano
7bc833016a Merge pull request #13 from heyitsanthony/weaken-single-put
test: use qconfig() instead of defaults in TestBucket_Put_Single
2017-08-09 08:41:24 -07:00
Anthony Romano
fd5de8495a fix NoSyncFreelist reachability checking
* unconditionally free freelist, if any, when committing txn

* only treat freelist pages as reachable if set to valid pgid

Fixes #9
2017-08-09 07:24:02 -07:00
Anthony Romano
1038faf165 test: use qconfig() instead of defaults in TestBucket_Put_Single
Default/nil quick.Config uses 1000 rounds, causing TestBucker_Put_Single to
run for over 3 minutes in CI. The default count (via qconfig()) for boltdb
is 5, so use that.
2017-08-09 00:30:52 -07:00
Anthony Romano
03f5e16968 freelist: read all free pages on count overflow
count is not shifted up by start index when taking subslice of free
list, dropping the last entry in the list.
2017-08-08 23:38:46 -07:00
Anthony Romano
f50ad8e90c test: check free page counts on close/reopen for freelist overflow
Confirm that the number of freed pages exceeds the overflow count, then check
that reopening gives the same number of free pages.
2017-08-08 23:37:24 -07:00
Gyu-Ho Lee
2ab139b399 Merge pull request #8 from gyuho/ci
gofmt, change git path
2017-07-27 15:05:25 -07:00
Gyu-Ho Lee
a30394a020 *: update git paths to 'coreos/bbolt' 2017-07-27 14:58:03 -07:00
Gyu-Ho Lee
7ce671beee *: fix gofmt style issues in 'range' 2017-07-27 14:57:54 -07:00
Anthony Romano
c359265bcd Merge pull request #6 from heyitsanthony/restore-freelist
rebuild freelist when opening with FreelistSync after NoFreelistSync
2017-07-25 10:02:42 -07:00
Anthony Romano
05bfb3bd9a rebuild freelist when opening with FreelistSync after NoFreelistSync
Writes pgidNoFreelist to the meta freelist page to detect when freelists
haven't been synced down.

Fixes #5
2017-07-25 08:01:43 -07:00
Xiang Li
ad39960eb4 Merge pull request #3 from heyitsanthony/range-gc
Garbage collect pages allocated after minimum txid
2017-06-23 18:19:54 -07:00
Xiang Li
572a8e0d3f Merge pull request #1 from coreos/no_sync
add option to skip freelist sync
2017-06-22 12:52:29 -07:00
Xiang
7149270521 *: add option to skip freelist sync
When the database has a lot of freepages, the cost to sync all
freepages down to disk is high. If the total database size is
small (<10GB), and the application can tolerate ~10 seconds
recovery time, then it is reasonable to simply not sync freelist
and rescan the db to rebuild freelist on recovery.
2017-06-22 12:46:56 -07:00
Xiang Li
bffefe5dd6 Merge pull request #4 from coreos/import_test
*: use coreos/bbolt as import path
2017-06-20 11:48:57 -07:00
Xiang
78b54a42e1 *: use coreos/bbolt as import path 2017-06-20 11:03:31 -07:00
Anthony Romano
78d099ed1f Garbage collect pages allocated after minimum txid
Read txns would lock pages allocated after the txn, keeping those pages
off the free list until closing the read txn. Instead, track allocating
txid to compute page lifetime, freeing pages if all txns between
page allocation and page free are closed.
2017-06-05 16:07:55 -07:00
Ben Johnson
e9cf4fae01 Merge pull request #654 from benbjohnson/revert-ca9f208
Revert "replace unix implementation to be the same as solaris to fix …"
2017-01-31 12:20:18 -07:00
Ben Johnson
82ecdfe9ef
Revert "replace unix implementation to be the same as solaris to fix an issue with glusterfs"
This reverts commit ca9f2088aab4fc9832e587655f0026875bddbf9b.
2017-01-31 07:53:51 -07:00
Ben Johnson
9145e04770 Merge pull request #651 from zweizeichen/master
hexidecimal -> hexadecimal
2017-01-30 08:30:26 -07:00
Sebastian
4660afd75e hexidecimal -> hexadecimal
Small spelling fix :)
2017-01-28 10:26:39 +01:00
Ben Johnson
a705895fda Merge pull request #642 from josharian/fix629
Ensure that keys generated by testing/quick are unique
2016-12-28 16:26:56 -07:00
Josh Bleecher Snyder
18ced60c94 Ensure that keys generated by testing/quick are unique
Quick seed 21691 used to generate duplicate keys, 
which caused some Puts of values to overwrite other values,
causing spurious test failures.

Fixes #629.
2016-12-28 14:09:56 -08:00
Ben Johnson
b9eb643780
Clean up timeout tests.
The new FCTNL locking does not support multiple locks from the
same process which makes those tests fail. The lock tests have
been removed.
2016-12-27 15:28:53 -07:00
Ben Johnson
2c3edd782c Merge pull request #616 from sinwav/idiomatic
Fix return statement inside else block at the end of function
2016-12-27 14:08:26 -07:00
Ben Johnson
ebe310138b Merge pull request #625 from vrecan/FcntlFlock
replace unix implementation to be the same as solaris to fix an issue with glusterfs
2016-12-27 14:07:51 -07:00
Ben Johnson
f57d45558d Merge pull request #628 from bep/patch-1
Fix prefix scan example
2016-12-27 14:06:03 -07:00
Ben Johnson
2e25e3bb42 Merge pull request #641 from josharian/cleanup
Minor cleanup and bug fixes
2016-12-23 10:44:54 -07:00
Josh Bleecher Snyder
10c6e01e1f Allow GC to reclaim completed transactions
The existing append-based implementation left a hanging reference to
the last tx.

For example, if db.txs was:

[]*Tx{0x1, 0x2, 0x3, 0x4, 0x5}

and we removed the second element, db.txs would now be:

[]*Tx{0x1, 0x3, 0x4, 0x5, 0x5}[:4]

The garbage collector cannot reclaim anything anywhere in a slice,
even pointers between its len and cap, because the len can always
be extended up to the cap.

This hanging reference to the Tx could last indefinitely,
and since the Tx has a reference to user-provided functions,
which could be closures, this bug could prevent arbitrary
amounts of user garbage from being collected.

Since db.txs is unordered anyway, switch to a simpler--and O(1) instead
of O(n)--implementation. Swap the last element into the spot to be
deleted, nil out the original last element, and shrink the slice.
2016-12-23 09:18:57 -08:00
Josh Bleecher Snyder
7adfa44e02 Fix freelist.size calculation for large freelists
freelist.size did not account for the extra
fake freelist item used to hold the number of
elements when the freelist is large.
2016-12-23 09:18:57 -08:00
Josh Bleecher Snyder
0e120dc470 Precalculate size of pending pgids in freelist.copyall
This recovers the slight alloc regression in #636.
2016-12-23 09:18:47 -08:00
Josh Bleecher Snyder
1858583b3b Clean up after #636
freelist.lenall duplicated freelist.count.
freelist.copyall and mergepgids docs had typos.
2016-12-23 08:56:04 -08:00
Ben Johnson
f0cf3bfd5b Merge pull request #636 from josharian/perf
Don't allocate huge slices to merge pgids in freelist.write
2016-12-21 16:46:06 -07:00
Ben Johnson
7614a4738b Merge pull request #638 from boltdb/fix-634
Document multi-process limitation in README
2016-12-21 08:52:53 -07:00
Ben Johnson
30095231de README
Add limitation about multiple processes opening databases concurrently.
2016-12-21 08:52:12 -07:00
Josh Bleecher Snyder
4d8824b05d Don't allocate huge slices to merge pgids in freelist.write
Using a large (50gb) database with a read-write-delete heavy load,
nearly 100% of allocated space came from freelists.
1/3 came from freelist.release, 1/3 from freelist.write,
and 1/3 came from tx.allocate to make space for freelist.write.
In the case of freelist.write, the newly allocated giant slice gets
copied to the space prepared by tx.allocate and then discarded.

To avoid this, add func mergepgids that accepts a destination slice,
and use it in freelist.write.

This has a mild negative impact on the existing benchmarks,
but cuts allocated space in my real world db by over 30%.

name                      old time/op    new time/op    delta
_FreelistRelease10K-8       18.7µs ±10%    18.2µs ± 4%    ~             (p=0.548 n=5+5)
_FreelistRelease100K-8       233µs ± 5%     258µs ±20%    ~             (p=0.151 n=5+5)
_FreelistRelease1000K-8     3.34ms ± 8%    3.13ms ± 8%    ~             (p=0.151 n=5+5)
_FreelistRelease10000K-8    32.3ms ± 1%    32.2ms ± 7%    ~             (p=0.690 n=5+5)
DBBatchAutomatic-8          2.18ms ± 3%    2.19ms ± 4%    ~             (p=0.421 n=5+5)
DBBatchSingle-8              140ms ± 6%     140ms ± 4%    ~             (p=0.841 n=5+5)
DBBatchManual10x100-8       4.41ms ± 2%    4.37ms ± 3%    ~             (p=0.548 n=5+5)

name                      old alloc/op   new alloc/op   delta
_FreelistRelease10K-8       82.5kB ± 0%    82.5kB ± 0%    ~     (all samples are equal)
_FreelistRelease100K-8       805kB ± 0%     805kB ± 0%    ~     (all samples are equal)
_FreelistRelease1000K-8     8.05MB ± 0%    8.05MB ± 0%    ~     (all samples are equal)
_FreelistRelease10000K-8    80.4MB ± 0%    80.4MB ± 0%    ~             (p=1.000 n=5+5)
DBBatchAutomatic-8           384kB ± 0%     384kB ± 0%    ~             (p=0.095 n=5+5)
DBBatchSingle-8             17.2MB ± 1%    17.2MB ± 1%    ~             (p=0.310 n=5+5)
DBBatchManual10x100-8        908kB ± 0%     902kB ± 1%    ~             (p=0.730 n=4+5)

name                      old allocs/op  new allocs/op  delta
_FreelistRelease10K-8         5.00 ± 0%      5.00 ± 0%    ~     (all samples are equal)
_FreelistRelease100K-8        5.00 ± 0%      5.00 ± 0%    ~     (all samples are equal)
_FreelistRelease1000K-8       5.00 ± 0%      5.00 ± 0%    ~     (all samples are equal)
_FreelistRelease10000K-8      5.00 ± 0%      5.00 ± 0%    ~     (all samples are equal)
DBBatchAutomatic-8           10.2k ± 0%     10.2k ± 0%  +0.07%          (p=0.032 n=5+5)
DBBatchSingle-8              58.6k ± 0%     59.6k ± 0%  +1.70%          (p=0.008 n=5+5)
DBBatchManual10x100-8        6.02k ± 0%     6.03k ± 0%  +0.17%          (p=0.029 n=4+4)
2016-12-20 14:32:15 -08:00