aboutsummaryrefslogtreecommitdiff
path: root/tx.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-05-27 12:08:33 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-05-27 12:08:33 -0600
commit93338e17eccebb077f96aabc7edc8f1c98c1b79d (patch)
treefe1fdb4aed24d100cac337e18afce207674fd65e /tx.go
parentMerge branch 'master' of https://github.com/boltdb/bolt (diff)
parentRemove DB.Check(). Allow read-only Tx.Check(). (diff)
downloaddedo-93338e17eccebb077f96aabc7edc8f1c98c1b79d.tar.gz
dedo-93338e17eccebb077f96aabc7edc8f1c98c1b79d.tar.xz
Merge pull request #174 from benbjohnson/remove-db-check
Remove DB.Check(). Allow read-only Tx.Check().
Diffstat (limited to 'tx.go')
-rw-r--r--tx.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/tx.go b/tx.go
index 8791adf..a0ae5bd 100644
--- a/tx.go
+++ b/tx.go
@@ -284,12 +284,14 @@ func (tx *Tx) CopyFile(path string, mode os.FileMode) error {
}
// Check performs several consistency checks on the database for this transaction.
-// An error is returned if any inconsistency is found or if executed on a read-only transaction.
+// An error is returned if any inconsistency is found.
+//
+// It can be safely run concurrently on a writable transaction. However, this
+// incurs a high cost for large databases and databases with a lot of subbuckets
+// because of caching. This overhead can be removed if running on a read-only
+// transaction, however, it is not safe to execute other writer transactions at
+// the same time.
func (tx *Tx) Check() error {
- if !tx.writable {
- return ErrTxNotWritable
- }
-
var errors ErrorList
// Check if any pages are double freed.
@@ -466,12 +468,10 @@ func (tx *Tx) forEachPage(pgid pgid, depth int, fn func(*page, int)) {
}
// Page returns page information for a given page number.
-// This is only available from writable transactions.
+// This is only safe for concurrent use when used by a writable transaction.
func (tx *Tx) Page(id int) (*PageInfo, error) {
if tx.db == nil {
return nil, ErrTxClosed
- } else if !tx.writable {
- return nil, ErrTxNotWritable
} else if pgid(id) >= tx.meta.pgid {
return nil, nil
}