diff --git a/logging/auto_roll_logger.cc b/logging/auto_roll_logger.cc index ec240f5a3..223dfbe30 100644 --- a/logging/auto_roll_logger.cc +++ b/logging/auto_roll_logger.cc @@ -46,9 +46,8 @@ AutoRollLogger::AutoRollLogger(Env* env, const std::string& dbname, } GetExistingFiles(); ResetLogger(); - s = TrimOldLogFiles(); - if (!status_.ok()) { - status_ = s; + if (status_.ok()) { + status_ = TrimOldLogFiles(); } } diff --git a/logging/auto_roll_logger_test.cc b/logging/auto_roll_logger_test.cc index fa668114c..dd279d62a 100644 --- a/logging/auto_roll_logger_test.cc +++ b/logging/auto_roll_logger_test.cc @@ -635,6 +635,15 @@ TEST_F(AutoRollLoggerTest, LogFileExistence) { delete db; } +TEST_F(AutoRollLoggerTest, FileCreateFailure) { + Options options; + options.max_log_file_size = 100 * 1024 * 1024; + options.db_log_dir = "/a/dir/does/not/exist/at/all"; + + std::shared_ptr logger; + ASSERT_NOK(CreateLoggerFromOptions("", options, &logger)); + ASSERT_TRUE(!logger); +} } // namespace rocksdb int main(int argc, char** argv) {