From b0a773c922a46941b96bc312352370c92ba38179 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 11 Jan 2020 19:14:32 -0800 Subject: [PATCH] ircd::db: Add conf item to repair on open. --- construct/construct.cc | 7 +++++++ include/ircd/db/database.h | 1 + ircd/db.cc | 21 ++++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/construct/construct.cc b/construct/construct.cc index 5a73db419..cc3d1a635 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -24,6 +24,7 @@ bool nolisten; bool noautomod; bool checkdb; bool pitrecdb; +bool repairdb; bool nojs; bool nodirect; bool noaio; @@ -51,6 +52,7 @@ lgetopt opts[] { "noautomod", &noautomod, lgetopt::BOOL, "Normal execution but without autoloading modules" }, { "checkdb", &checkdb, lgetopt::BOOL, "Perform complete checks of databases when opening" }, { "pitrecdb", &pitrecdb, lgetopt::BOOL, "Allow Point-In-Time-Recover if DB reports corruption after crash" }, + { "repairdb", &repairdb, lgetopt::BOOL, "Perform full DB repair after deep block/file corruption." }, { "nojs", &nojs, lgetopt::BOOL, "Disable SpiderMonkey JS subsystem from initializing. (noop when not available)." }, { "nodirect", &nodirect, lgetopt::BOOL, "Disable direct IO (O_DIRECT) for unsupporting filesystems." }, { "noaio", &noaio, lgetopt::BOOL, "Disable the AIO interface in favor of traditional syscalls. " }, @@ -468,6 +470,11 @@ applyargs() else ircd::db::open_recover.set("absolute"); + if(repairdb) + ircd::db::open_repair.set("true"); + else + ircd::db::open_repair.set("false"); + if(nodirect) ircd::fs::fd::opts::direct_io_enable.set("false"); else diff --git a/include/ircd/db/database.h b/include/ircd/db/database.h index a5e603414..5656cb622 100644 --- a/include/ircd/db/database.h +++ b/include/ircd/db/database.h @@ -18,6 +18,7 @@ namespace ircd::db // Broad conf items extern conf::item open_check; extern conf::item open_recover; + extern conf::item open_repair; // General information const std::string &name(const database &); diff --git a/ircd/db.cc b/ircd/db.cc index 4fff07842..5fb5b95d5 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -383,6 +383,25 @@ ircd::db::open_recover { "persist", false }, }; +/// Conf item determines if database repair should occur (before open). This +/// mechanism can be used when SST file corruption occurs which is too deep +/// for log-based recovery. The affected blocks may be discarded; this risks +/// destabilizing an application expecting the data in those blocks to exist. +/// +/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/// +/// Use with caution. +/// +/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/// +decltype(ircd::db::open_repair) +ircd::db::open_repair +{ + { "name", "ircd.db.open.repair" }, + { "default", false }, + { "persist", false }, +}; + void ircd::db::sync(database &d) { @@ -1098,7 +1117,7 @@ try } ,fsck { - false + db::open_repair } ,read_only {