mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-25 14:31:35 +00:00
Fix regression bug of Auto rolling logger when handling failures (#5622)
Summary: Auto roll logger fails to handle file creation error in the correct way, which may expose to seg fault condition to users. Fix it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5622 Test Plan: Add a unit test on creating file under a non-existing directory. The test fails without the fix. Differential Revision: D16460853 fbshipit-source-id: e96da4bef4f16db171ea04a11b2ec5a9448ddbde
This commit is contained in:
parent
66b524a911
commit
5daa426a18
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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> logger;
|
||||
ASSERT_NOK(CreateLoggerFromOptions("", options, &logger));
|
||||
ASSERT_TRUE(!logger);
|
||||
}
|
||||
} // namespace rocksdb
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
|
Loading…
Reference in a new issue