From 9d5afc8e87385133ad5a4966247ffba04848c2fe Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 22 May 2018 16:52:34 -0700 Subject: [PATCH] ircd::db: Add separate check(database); Add log notice when checking on open. --- include/ircd/db/database/database.h | 1 + ircd/db.cc | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/ircd/db/database/database.h b/include/ircd/db/database/database.h index 4b459e5f1..8de308c90 100644 --- a/include/ircd/db/database/database.h +++ b/include/ircd/db/database/database.h @@ -50,6 +50,7 @@ namespace ircd::db void setopt(database &, const string_view &key, const string_view &val); void fdeletions(database &, const bool &enable, const bool &force = false); void checkpoint(database &, const string_view &dir); + void check(database &); void compact(database &); void sort(database &, const bool &blocking = true); void flush(database &, const bool &sync = false); diff --git a/ircd/db.cc b/ircd/db.cc index b6c4b7981..f13ae5eb6 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -174,6 +174,16 @@ ircd::db::compact(database &d) } } +void +ircd::db::check(database &d) +{ + assert(d.d); + throw_on_error + { + d.d->VerifyChecksum() + }; +} + /// Writes a snapshot of this database to the directory specified. The /// snapshot consists of hardlinks to the bulk data files of this db, but /// copies the other stuff that usually gets corrupted. The directory can @@ -629,12 +639,14 @@ try dbs, dbs.emplace(string_view{this->name}, this).first } { - throw_on_error + #ifdef RB_DEBUG + log::notice { - #ifdef RB_DEBUG - d->VerifyChecksum() //TODO: worth doing this for real here? - #endif + log, "'%s': Verifying database integrity. This may take several minutes...", + this->name }; + check(*this); + #endif log.info("'%s': Opened database @ `%s' with %zu columns at sequence number %lu.", this->name,