Commit Graph

306 Commits (b9899d09ab6c032b54fe4a09e9389dff28d8a7f8)

Author SHA1 Message Date
Ben Johnson 3f7dbffa2e Merge pull request #119 from benbjohnson/tx-rename
Rename internal local Tx variables.
2014-04-04 12:04:53 -06:00
Ben Johnson 12204df0b5 Rename internal local Tx variables.
This commit changes the local Tx variables from "t" to "tx". This is partly
for consistency with external documentation but also because it just
annoys me for some reason.
2014-04-04 12:03:04 -06:00
Ben Johnson af1551e8dd Merge pull request #118 from benbjohnson/commit-hook
Add Tx.OnCommit() handler.
2014-04-04 11:21:33 -06:00
Ben Johnson 394e42e3eb Add Tx.OnCommit() handler.
This commit adds the ability to execute a function after a transaction has
successfully committed.
2014-04-04 07:59:24 -06:00
Ben Johnson d667ae0fe1 README
Add 'Scuttlebutt' to list of projects that use Bolt.
2014-04-03 09:31:34 -06:00
Ben Johnson 71fa5d8610 Merge pull request #113 from benbjohnson/meta-checksum
Add meta page checksums.
2014-04-02 17:02:41 -06:00
Ben Johnson ca83d17125 Add meta page checksums.
This commit adds checksums to the meta pages on every write. When the
database loads, it verifies the checksums on the meta pages and returns
an error if either one is corrupt.

In the future, it should fallback to the previous meta page but for right
now it just hard fails. This is at least preferable to opening the database
and getting a random error or further corruption.

Fixes #25.
2014-04-02 16:56:16 -06:00
Ben Johnson 20a1479c4c Merge pull request #112 from benbjohnson/perf-stats
Add performance counters.
2014-04-02 16:03:16 -06:00
Ben Johnson 686b6a3341 Add performance counters.
This commit adds performance counters for each transaction which are rolled
up to the database level on each commit/rollback. Counters are meant to be
a very fast way to track what is going on in the database. A few timers are
also added in areas where the time.Now() overhead is not noticible.

The DB.Stat() function is now deprecated since the `bolt` CLI now performs
similar functions.

Fixes #108.
2014-04-02 16:03:03 -06:00
Ben Johnson c5823a20bd Merge pull request #111 from benbjohnson/flock
Add advisory file locking.
2014-04-02 14:09:28 -06:00
Ben Johnson 1eacfa9489 Add advisory file locking.
This commit adds advisory locking via flock() to the database file. This ensures that two separate
processes cannot both open the same data file which would cause corruption.

Fixes #110.
2014-04-02 14:05:24 -06:00
Ben Johnson 1c3ebaebae Merge pull request #109 from benbjohnson/consolidate-file-descriptors
Consolidate file and metafile descriptors.
2014-04-02 13:58:03 -06:00
Ben Johnson 4ef19124d1 Consolidate file and metafile descriptors.
Previously, a two file descriptors were used for the database: file & metafile. The "file" file
descriptor was used for async writes while the "metafile" file descriptor was used with O_SYNC
writes. This commit changes that so that there's only one file descriptor and it uses fdatasync()
to synchronize writes.
2014-04-02 13:50:03 -06:00
Ben Johnson 76acd60ff3 README
Remove the 'Internals' section since it is half-assed right now.
2014-04-02 10:28:17 -06:00
Ben Johnson 8c5646982c Merge branch 'master' of https://github.com/boltdb/bolt 2014-04-02 07:46:47 -06:00
Ben Johnson 43eda94ec1 Remove count and overflow columns for free pages on 'bolt pages'.
The count and overflow columns are meaningless for freed pages since
there could be random overflow data in there. This commit removes those
columns for free pages.
2014-04-02 07:44:54 -06:00
Ben Johnson 4364c2f7f6 Merge pull request #107 from DocSavage/master
Add DVID to projects using Bolt
2014-03-31 13:31:26 -06:00
Bill Katz 6dd15bbf70 Add DVID to projects using Bolt
DVID added Bolt as an optional storage engine.
2014-03-31 15:25:05 -04:00
Ben Johnson 4870e5fe8c Merge pull request #104 from benbjohnson/remove-db-open
Remove DB.Open() and only allow bolt.Open().
2014-03-31 12:03:53 -06:00
Ben Johnson 8dafb2312b Remove DB.Open() and only allow bolt.Open().
Per @tv42's suggestion, this commit removes the ability to reopen an
instance of DB. All open calls go through bolt.Open().

Fixes #103.
2014-03-31 11:22:27 -06:00
Ben Johnson b5c1715a36 Merge pull request #102 from benbjohnson/fix-freelist
Write freelist after each commit.
2014-03-31 11:08:27 -06:00
Ben Johnson 440b89418f Write freelist after each commit.
Well, this is embarassing. Somehow the freelist was never getting written after each commit.
This commit fixes that and fixes a small reporting issue with "bolt pages".
2014-03-31 08:52:19 -06:00
Ben Johnson fcce87626c Merge pull request #98 from benbjohnson/fsck
Add DB.Check().
2014-03-29 14:28:53 -06:00
Ben Johnson 7f2de9f17a Add DB.Check(). 2014-03-29 14:22:32 -06:00
Ben Johnson 7dafeaa896 Merge pull request #97 from benbjohnson/cli
Refactor bolt commands into individual files.
2014-03-27 22:39:29 -06:00
Ben Johnson fea388b03d Refactor bolt commands into individual files. 2014-03-27 22:36:05 -06:00
Ben Johnson b10aa18c88 Merge pull request #92 from benbjohnson/safe-copy
Fix DB.Copy() meta lock and partial write checks.
2014-03-26 11:00:25 -06:00
Ben Johnson f45f1ed8d4 Fix DB.Copy() meta lock and partial write checks. 2014-03-26 10:11:31 -06:00
Ben Johnson 2327fd97d7 Merge pull request #91 from benbjohnson/quickcheck
Fix quickcheck test for duplicate keys.
2014-03-25 08:21:58 -06:00
Ben Johnson 03ba0d1d4d Fix quickcheck test for duplicate keys. 2014-03-25 08:20:21 -06:00
Ben Johnson 381d08dffd Merge pull request #90 from benbjohnson/fix-bucket-reclamation
Fix bucket reclamation
2014-03-25 07:31:49 -06:00
Ben Johnson d8e4cffa12 Fix bucket reclamation.
The bucket page is allocated separately from the rest of the pages but the old bucket pages were
not being added to the freelist. This change fixes that and adds a simple check for database
consistency. More advanced consistency checks can be added in the future.

Fixes #82.
2014-03-25 07:25:00 -06:00
Ben Johnson 32da80f953 README
Add a list of "Other Projects Using Bolt".
2014-03-24 13:41:08 -06:00
Ben Johnson 2bc868c466 Merge pull request #88 from benbjohnson/tx-rename
Make DB/Tx API more consistent.
2014-03-24 11:46:58 -06:00
Ben Johnson f8ad21bad3 Make DB/Tx API more consistent.
I consolidated the DB.Tx() and DB.RWTx() calls into a single
DB.Begin(writable bool) call. This is more consistent with the
database/sql library.

I also changed the DB.Do() and DB.With() call to DB.Update() and
DB.View(), respectively. This is more intuitive and more inline with
other database verbiage.
2014-03-24 11:43:06 -06:00
Ben Johnson 0866abf733 Merge pull request #87 from benbjohnson/errors
Error refactoring
2014-03-24 08:32:38 -06:00
Ben Johnson 59fde2f664 Error refactoring.
Fixed up a few error issues and refactored out the Error type.
2014-03-24 08:31:15 -06:00
Ben Johnson 7ea635c8fc Merge pull request #86 from benbjohnson/mock
Re-add tests for write failures
2014-03-24 07:49:09 -06:00
Tommi Virtanen e9b2cab0fa Re-add tests for write failures
Commit d2173f5f0e removed the complete
os & syscall mocking layer as overly complex. This commit adds back
the simplest possible thing: hooks to control the database file
writes.

Missing tests: TestDBOpenMetaFileError, TestDBMmapStatError.
These are harder to test without more extensive mocking.

Conflicts:
	db_test.go
2014-03-24 07:47:33 -06:00
Ben Johnson 3c1ecb925e Resolve remaining errcheck warnings. 2014-03-24 07:38:27 -06:00
Tommi Virtanen e0a6f5b2af Check errors from file close in DB.CopyFile
Write errors are often delayed and reported only by the close.

The extra close in defer on success is harmless, (*os.File).Close
protects itself against multiple closes, and this way it's immediately
obvious there is no code path that would leak open files.
2014-03-23 13:27:37 -07:00
Tommi Virtanen cb896f6525 Check spill error in Commit 2014-03-23 13:27:37 -07:00
Tommi Virtanen bfb02aec20 Check meta page write error in Commit 2014-03-23 13:27:36 -07:00
Ben Johnson 42bc0f210a Merge pull request #81 from benbjohnson/tx-closed
Add ErrTxClosed error.
2014-03-23 12:24:32 -06:00
Ben Johnson 482f00fdfc Add ErrTxClosed error.
Commit/Rollback and mutable calls on Tx and Bucket now return ErrTxClosed
if the transaction has already been committed or rolled back. Non-mutable
calls have added an assertion to check if the transaction is closed which
will cause a panic. I don't want to introduce an error return for accessor
methods that are being used improperly so I think the panic is appropriate.
2014-03-23 12:20:16 -06:00
Ben Johnson 8303617b72 Merge pull request #78 from benbjohnson/tx-managed
Mark Do()/With() transaction as managed.
2014-03-23 11:52:10 -06:00
Ben Johnson 76f6ead6b0 Mark Do()/With() transaction as managed.
Transaction created from Do() and With() are now considered "managed".
Managed transactions cannot be manually committed or rolled back since
the Do() and With() functions provide that functionally automatically.
Previously, a Tx could be manually committed and then any changes after
that would be lost.
2014-03-23 10:34:53 -06:00
Ben Johnson 1282a4aff7 Merge pull request #76 from benbjohnson/fsync
fdatasync
2014-03-23 10:01:58 -06:00
Ben Johnson a10ce47f54 Consolidate syscall files. 2014-03-23 08:59:45 -07:00
Ben Johnson fd8a13e837 Merge branch 'fdatasync' of https://github.com/tv42/bolt into fsync 2014-03-23 09:42:21 -06:00