aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-07-23 15:44:17 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-07-23 15:44:17 -0600
commit5fb781318ffe555f3eac13c2dee677e1a278828a (patch)
treed9a6eb8f34baf289c8cb931620bb4e8d32b704a0 /db_test.go
parentMerge pull request #227 from benbjohnson/fix-double-spill (diff)
parentFix root split on very large append. (diff)
downloaddedo-5fb781318ffe555f3eac13c2dee677e1a278828a.tar.gz
dedo-5fb781318ffe555f3eac13c2dee677e1a278828a.tar.xz
Merge pull request #228 from benbjohnson/fix-large-append
Fix root split on very large append.
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go37
1 files changed, 29 insertions, 8 deletions
diff --git a/db_test.go b/db_test.go
index 0809bcb..2063249 100644
--- a/db_test.go
+++ b/db_test.go
@@ -608,15 +608,36 @@ 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) {
- err := db.View(func(tx *Tx) error {
- return <-tx.Check()
+ db.View(func(tx *Tx) error {
+ // Collect all the errors.
+ var errors []error
+ for err := range tx.Check() {
+ errors = append(errors, err)
+ if len(errors) > 10 {
+ break
+ }
+ }
+
+ // If errors occurred, copy the DB and print the errors.
+ if len(errors) > 0 {
+ var path = tempfile()
+ tx.CopyFile(path, 0600)
+
+ // Print errors.
+ fmt.Print("\n\n")
+ fmt.Printf("consistency check failed (%d errors)\n", len(errors))
+ for _, err := range errors {
+ fmt.Println(err)
+ }
+ fmt.Println("")
+ fmt.Println("db saved to:")
+ fmt.Println(path)
+ fmt.Print("\n\n")
+ os.Exit(-1)
+ }
+
+ return nil
})
- if err != nil {
- // Copy db off first.
- var path = tempfile()
- db.View(func(tx *Tx) error { return tx.CopyFile(path, 0600) })
- panic("check failure: " + err.Error() + ": " + path)
- }
}
// mustContainKeys checks that a bucket contains a given set of keys.