From 92a9f2e200e83fd0b3ddef177f9a454b0273c17e Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 27 May 2014 11:31:55 -0600 Subject: 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. --- db_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'db_test.go') diff --git a/db_test.go b/db_test.go index b85f8cb..06accd3 100644 --- a/db_test.go +++ b/db_test.go @@ -53,12 +53,12 @@ func TestOpen_Check(t *testing.T) { withTempPath(func(path string) { db, err := Open(path, 0666) assert.NoError(t, err) - assert.NoError(t, db.Check()) + assert.NoError(t, db.View(func(tx *Tx) error { return tx.Check() })) db.Close() db, err = Open(path, 0666) assert.NoError(t, err) - assert.NoError(t, db.Check()) + assert.NoError(t, db.View(func(tx *Tx) error { return tx.Check() })) db.Close() }) } @@ -463,7 +463,10 @@ func withOpenDB(fn func(*DB, string)) { // mustCheck runs a consistency check on the database and panics if any errors are found. func mustCheck(db *DB) { - if err := db.Check(); err != nil { + err := db.Update(func(tx *Tx) error { + return tx.Check() + }) + if err != nil { // Copy db off first. var path = tempfile() db.View(func(tx *Tx) error { return tx.CopyFile(path, 0600) }) -- cgit v1.2.3