]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix incorrect Status::NoSpace() status check (#8504)
authorZhichao Cao <zhichao@fb.com>
Wed, 21 Jul 2021 01:08:55 +0000 (18:08 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 21 Jul 2021 01:09:51 +0000 (18:09 -0700)
Summary:
If we want to check whether a Status s is NoSpace() or not, we should check the subcode instread of using s==Status::NoSpace(). Fix some of the incorrect check in the ErrorHandler.

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

Test Plan: make check

Reviewed By: anand1976

Differential Revision: D29601764

Pulled By: zhichao-cao

fbshipit-source-id: cdab56a827891c23746bba9cbb53f169fe35f086

db/error_handler.cc
file/sst_file_manager_impl.cc
utilities/fault_injection_env.h
utilities/fault_injection_fs.h

index b5c353a69082f7f3e8b3bb26e1ad38513da863ce..38b4fa0497f5d3b572c3742c5ed6876d161cd14b 100644 (file)
@@ -327,7 +327,8 @@ const Status& ErrorHandler::SetBGError(const Status& bg_err,
   }
 
   // Allow some error specific overrides
-  if (new_bg_err == Status::NoSpace()) {
+  if (new_bg_err.subcode() == IOStatus::SubCode::kNoSpace ||
+      new_bg_err.subcode() == IOStatus::SubCode::kSpaceLimit) {
     new_bg_err = OverrideNoSpaceError(new_bg_err, &auto_recovery);
   }
 
@@ -349,7 +350,8 @@ const Status& ErrorHandler::SetBGError(const Status& bg_err,
     recovery_in_prog_ = true;
 
     // Kick-off error specific recovery
-    if (bg_error_ == Status::NoSpace()) {
+    if (new_bg_err.subcode() == IOStatus::SubCode::kNoSpace ||
+        new_bg_err.subcode() == IOStatus::SubCode::kSpaceLimit) {
       RecoverFromNoSpace();
     }
   }
index cc03e54441d49e0c7753c1733b3c82ee89ab7139..161602fa77392c0f522e77bd39c506ac5881874a 100644 (file)
@@ -317,7 +317,7 @@ void SstFileManagerImpl::ClearError() {
         // error is also a NoSpace() non-fatal error, leave the instance in
         // the list
         Status err = cur_instance_->GetBGError();
-        if (s.ok() && err == Status::NoSpace() &&
+        if (s.ok() && err.subcode() == IOStatus::SubCode::kNoSpace &&
             err.severity() < Status::Severity::kFatalError) {
           s = err;
         }
index ab232a1a26b2ecb7b5ea5bec5ebea083340e83ff..fa1fa0d64a9b60b22068026809145e6f824b285d 100644 (file)
@@ -179,7 +179,8 @@ class FaultInjectionTestEnv : public EnvWrapper {
 #undef GetFreeSpace
   virtual Status GetFreeSpace(const std::string& path,
                               uint64_t* disk_free) override {
-    if (!IsFilesystemActive() && error_ == Status::NoSpace()) {
+    if (!IsFilesystemActive() &&
+        error_.subcode() == IOStatus::SubCode::kNoSpace) {
       *disk_free = 0;
       return Status::OK();
     } else {
index 625911af3a5118f023e8b3b915233ebb5cdb9df2..62c938ca0f9988fa9fe408ce1faef1baefb9096b 100644 (file)
@@ -240,7 +240,8 @@ class FaultInjectionTestFS : public FileSystemWrapper {
                                 const IOOptions& options, uint64_t* disk_free,
                                 IODebugContext* dbg) override {
     IOStatus io_s;
-    if (!IsFilesystemActive() && error_ == IOStatus::NoSpace()) {
+    if (!IsFilesystemActive() &&
+        error_.subcode() == IOStatus::SubCode::kNoSpace) {
       *disk_free = 0;
     } else {
       io_s = target()->GetFreeSpace(path, options, disk_free, dbg);