0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-30 02:32:43 +01:00

ircd::db: Add additional recovery mode if supported.

This commit is contained in:
Jason Volk 2020-06-09 20:20:22 -07:00
parent b68b4d113a
commit c037519246
2 changed files with 15 additions and 1 deletions

View file

@ -27,6 +27,7 @@ bool noautomod;
bool nocompact;
bool checkdb;
bool pitrecdb;
bool recoverdb;
bool repairdb;
bool nojs;
bool nodirect;
@ -58,6 +59,7 @@ lgetopt opts[]
{ "nocompact", &nocompact, lgetopt::BOOL, "Disable automatic database compaction" },
{ "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" },
{ "recoverdb", &recoverdb, lgetopt::BOOL, "Allow earlier Point-In-Time when -pitrecdb does not work" },
{ "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" },
@ -510,6 +512,9 @@ applyargs()
else
ircd::db::open_recover.set("absolute");
if(recoverdb)
ircd::db::open_recover.set("recover");
if(repairdb)
ircd::db::open_repair.set("true");
else

View file

@ -1319,9 +1319,18 @@ try
// When corrupted after crash, the DB is rolled back before the first
// corruption and erases everything after it, giving a consistent
// state up at that point, though losing some recent data.
if(string_view(open_recover) == "point")
if(string_view(open_recover) == "point" || string_view(open_recover) == "recover")
opts->wal_recovery_mode = rocksdb::WALRecoveryMode::kPointInTimeRecovery;
// When corrupted after crash and PointInTimeRecovery does not work,
// this will drop more data, but consistently. RocksDB sez the WAL is not
// used at all in this mode.
#if ROCKSDB_MAJOR > 6 \
|| (ROCKSDB_MAJOR == 6 && ROCKSDB_MINOR >= 10)
if(string_view(open_recover) == "recover")
opts->best_efforts_recovery = true;
#endif
// Skipping corrupted records will create gaps in the DB timeline where the
// application (like a matrix timeline) cannot tolerate the unexpected gap.
if(string_view(open_recover) == "skip")