]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix bug in Logger creation if dbname and db_log_dir are on different filesystem ...
authorAkanksha Mahajan <akankshamahajan@fb.com>
Fri, 1 Jul 2022 02:04:25 +0000 (19:04 -0700)
committerakankshamahajan <akankshamahajan@fb.com>
Fri, 1 Jul 2022 02:12:53 +0000 (19:12 -0700)
Summary:
If dbname and db_log_dir are at different filesystems (one
local and one remote), creation of dbname will fail because that path
doesn't exist wrt to db_log_dir.
This patch will ignore the error returned on creation of dbname. If they
are on same filesystem, db_log_dir creation will automatically return
the error in case there is any error in creation of dbname.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10292

Test Plan: Existing unit tests

Reviewed By: riversand963

Differential Revision: D37567773

Pulled By: akankshamahajan15

fbshipit-source-id: 005d28c536208d4c126c8cb8e196d1d85b881100

HISTORY.md
logging/auto_roll_logger.cc

index 1e697c0e3b810fa24f936b9be93a9452d80cf9e2..24fc938635fc417b6497976703cd0daff7be92c9 100644 (file)
@@ -1,4 +1,8 @@
 # Rocksdb Change Log
+## Unreleased
+### Bug Fixes
+Fix a bug in Logger where if dbname and db_log_dir are on different filesystems, dbname creation would fail wrt to db_log_dir path returning an error and fails to open the DB.
+
 ## 7.4.1 (06/28/2022)
 ### Bug Fixes
 * Pass `rate_limiter_priority` through filter block reader functions to `FileSystem`.
index cfc8d43713d1c552d3a2552934c07af882788665..a362b6f238b9fc2ecac024925a4b974763ae7041 100644 (file)
@@ -278,11 +278,21 @@ Status CreateLoggerFromOptions(const std::string& dbname,
       InfoLogFileName(dbname, db_absolute_path, options.db_log_dir);
 
   const auto& clock = env->GetSystemClock();
-  // In case it does not exist
+  // In case it does not exist.
   s = env->CreateDirIfMissing(dbname);
   if (!s.ok()) {
-    return s;
+    if (options.db_log_dir.empty()) {
+      return s;
+    } else {
+      // Ignore the error returned during creation of dbname because dbname and
+      // db_log_dir can be on different filesystems in which case dbname will
+      // not exist and error should be ignored. db_log_dir creation will handle
+      // the error in case there is any error in the creation of dbname on same
+      // filesystem.
+      s = Status::OK();
+    }
   }
+  assert(s.ok());
 
   if (!options.db_log_dir.empty()) {
     s = env->CreateDirIfMissing(options.db_log_dir);