From 11f329bd40ff6d6cd730e3dd276c5662188538a0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 17 Mar 2016 14:38:27 -0400 Subject: [PATCH] db/db_impl: restrict WALRecoveryMode when using recycled log files kPointInTimeRecovery is indistinguishable from kTolerateCorruptedTailRecords in recycle mode since we define the "end" of the log as the first corrupt record we encounter. kAbsoluteConsistency doesn't make sense because even a clean shutdown leaves old junk at the end of the log file. Signed-off-by: Sage Weil --- db/db_impl.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/db/db_impl.cc b/db/db_impl.cc index 8191d291c..86105a831 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -169,6 +169,17 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) { result.recycle_log_file_num = false; } + if (result.recycle_log_file_num && + (result.wal_recovery_mode == WALRecoveryMode::kPointInTimeRecovery || + result.wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency)) { + // kPointInTimeRecovery is indistinguishable from + // kTolerateCorruptedTailRecords in recycle mode since we define + // the "end" of the log as the first corrupt record we encounter. + // kAbsoluteConsistency doesn't make sense because even a clean + // shutdown leaves old junk at the end of the log file. + result.wal_recovery_mode = WALRecoveryMode::kTolerateCorruptedTailRecords; + } + if (result.wal_dir.empty()) { // Use dbname as default result.wal_dir = dbname;