From 5ac97314e70eb7fcfbb6965c938766ae5dc6d6da Mon Sep 17 00:00:00 2001 From: Changli Gao Date: Fri, 20 Jan 2017 13:11:13 -0800 Subject: [PATCH] Fix std::out_of_range when DBOptions::keep_log_file_num is zero Summary: We should validate this option, otherwise we may see std::out_of_range thrown at: db/db_impl.cc:1124 1123 for (unsigned int i = 0; i <= end; i++) { 1124 std::string& to_delete = old_info_log_files.at(i); 1125 std::string full_path_to_delete = 1126 (immutable_db_options_.db_log_dir.empty() Closes https://github.com/facebook/rocksdb/pull/1722 Differential Revision: D4379495 Pulled By: yiwu-arbug fbshipit-source-id: e136552 --- db/db_impl.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/db_impl.cc b/db/db_impl.cc index 19165e95c..0fbcb4d9d 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -268,6 +268,10 @@ static Status ValidateOptions( "then direct I/O writes (use_direct_writes) must be disabled. "); } + if (db_options.keep_log_file_num == 0) { + return Status::InvalidArgument("keep_log_file_num must be greater than 0"); + } + return Status::OK(); }