0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd::db: Add separate check(database); Add log notice when checking on open.

This commit is contained in:
Jason Volk 2018-05-22 16:52:34 -07:00
parent 02fde9e09f
commit 9d5afc8e87
2 changed files with 17 additions and 4 deletions

View file

@ -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);

View file

@ -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,