]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Add db_test2 to to ASSERT_STATUS_CHECKED (#8640)
authorAdam Retter <adam.retter@googlemail.com>
Mon, 16 Aug 2021 15:09:46 +0000 (08:09 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 16 Aug 2021 15:10:32 +0000 (08:10 -0700)
Summary:
This is the `db_test2` parts of https://github.com/facebook/rocksdb/pull/7737 reworked on the latest HEAD.

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

Reviewed By: akankshamahajan15

Differential Revision: D30303684

Pulled By: mrambacher

fbshipit-source-id: 263e2f82d849bde4048b60aed8b31e7deed4706a

Makefile
db/db_impl/db_impl.cc
db/db_impl/db_impl_open.cc
db/db_test2.cc
db/db_test_util.h
file/filename.cc
table/block_fetcher.h

index a1e0f77059b25a7f75b97938a9e28b9551fda81a..77ce2dd83ad87d37f912b5a04bf0599a2a26dcfa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -525,7 +525,6 @@ ifdef ASSERT_STATUS_CHECKED
        TESTS_FAILING_ASC = \
                c_test \
                db_test \
-               db_test2 \
                env_test \
                range_locking_test \
                testutil_test \
index ef6a9cbda5761d0f78b4736358910843a5f6acd4..20c3c2bd426352cad46c20b1b6e49df252949041 100644 (file)
@@ -5103,7 +5103,7 @@ Status DBImpl::EndTrace() {
     s = tracer_->Close();
     tracer_.reset();
   } else {
-    return Status::IOError("No trace file to close");
+    s = Status::IOError("No trace file to close");
   }
   return s;
 }
index 47e26ede8e9abdabc1831bb67690968e0ae6ba17..25e4bc5a383b0f2b690b23363e25643309fb62b8 100644 (file)
@@ -1434,8 +1434,10 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
                       meta.fd.GetFileSize(), s.ToString().c_str());
       mutex_.Lock();
 
-      io_s.PermitUncheckedError();  // TODO(AR) is this correct, or should we
-                                    // return io_s if not ok()?
+      // TODO(AR) is this ok?
+      if (!io_s.ok() && s.ok()) {
+        s = io_s;
+      }
     }
   }
   ReleaseFileNumberFromPendingOutputs(pending_outputs_inserted_elem);
index a7f82db1bac9319f320513edc6e8a1dfd5fd4d4b..c6e807c1eaf0b29750dacf8e196c2e98dadcd88c 100644 (file)
@@ -233,7 +233,7 @@ TEST_P(PrefixFullBloomWithReverseComparator,
   ASSERT_OK(dbfull()->Put(WriteOptions(), "bar234", "foo2"));
   ASSERT_OK(dbfull()->Put(WriteOptions(), "foo123", "foo3"));
 
-  dbfull()->Flush(FlushOptions());
+  ASSERT_OK(dbfull()->Flush(FlushOptions()));
 
   if (bbto.block_cache) {
     bbto.block_cache->EraseUnRefEntries();
@@ -265,18 +265,20 @@ INSTANTIATE_TEST_CASE_P(PrefixFullBloomWithReverseComparator,
                         PrefixFullBloomWithReverseComparator, testing::Bool());
 
 TEST_F(DBTest2, IteratorPropertyVersionNumber) {
-  Put("", "");
+  ASSERT_OK(Put("", ""));
   Iterator* iter1 = db_->NewIterator(ReadOptions());
+  ASSERT_OK(iter1->status());
   std::string prop_value;
   ASSERT_OK(
       iter1->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
   uint64_t version_number1 =
       static_cast<uint64_t>(std::atoi(prop_value.c_str()));
 
-  Put("", "");
-  Flush();
+  ASSERT_OK(Put("", ""));
+  ASSERT_OK(Flush());
 
   Iterator* iter2 = db_->NewIterator(ReadOptions());
+  ASSERT_OK(iter2->status());
   ASSERT_OK(
       iter2->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
   uint64_t version_number2 =
@@ -284,9 +286,10 @@ TEST_F(DBTest2, IteratorPropertyVersionNumber) {
 
   ASSERT_GT(version_number2, version_number1);
 
-  Put("", "");
+  ASSERT_OK(Put("", ""));
 
   Iterator* iter3 = db_->NewIterator(ReadOptions());
+  ASSERT_OK(iter3->status());
   ASSERT_OK(
       iter3->GetProperty("rocksdb.iterator.super-version-number", &prop_value));
   uint64_t version_number3 =
@@ -316,8 +319,8 @@ TEST_F(DBTest2, CacheIndexAndFilterWithDBRestart) {
   options.table_factory.reset(NewBlockBasedTableFactory(table_options));
   CreateAndReopenWithCF({"pikachu"}, options);
 
-  Put(1, "a", "begin");
-  Put(1, "z", "end");
+  ASSERT_OK(Put(1, "a", "begin"));
+  ASSERT_OK(Put(1, "z", "end"));
   ASSERT_OK(Flush(1));
   TryReopenWithColumnFamilies({"default", "pikachu"}, options);
 
@@ -333,10 +336,10 @@ TEST_F(DBTest2, MaxSuccessiveMergesChangeWithDBRecovery) {
   options.merge_operator = MergeOperators::CreatePutOperator();
   options.disable_auto_compactions = true;
   DestroyAndReopen(options);
-  Put("poi", "Finch");
-  db_->Merge(WriteOptions(), "poi", "Reese");
-  db_->Merge(WriteOptions(), "poi", "Shaw");
-  db_->Merge(WriteOptions(), "poi", "Root");
+  ASSERT_OK(Put("poi", "Finch"));
+  ASSERT_OK(db_->Merge(WriteOptions(), "poi", "Reese"));
+  ASSERT_OK(db_->Merge(WriteOptions(), "poi", "Shaw"));
+  ASSERT_OK(db_->Merge(WriteOptions(), "poi", "Root"));
   options.max_successive_merges = 2;
   Reopen(options);
 }
@@ -398,10 +401,10 @@ TEST_P(DBTestSharedWriteBufferAcrossCFs, SharedWriteBufferAcrossCFs) {
   wo.disableWAL = true;
 
   std::function<void()> wait_flush = [&]() {
-    dbfull()->TEST_WaitForFlushMemTable(handles_[0]);
-    dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
-    dbfull()->TEST_WaitForFlushMemTable(handles_[2]);
-    dbfull()->TEST_WaitForFlushMemTable(handles_[3]);
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[0]));
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1]));
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[2]));
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[3]));
   };
 
   // Create some data and flush "default" and "nikitich" so that they
@@ -576,10 +579,10 @@ TEST_F(DBTest2, SharedWriteBufferLimitAcrossDB) {
   wo.disableWAL = true;
 
   std::function<void()> wait_flush = [&]() {
-    dbfull()->TEST_WaitForFlushMemTable(handles_[0]);
-    dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
-    dbfull()->TEST_WaitForFlushMemTable(handles_[2]);
-    static_cast<DBImpl*>(db2)->TEST_WaitForFlushMemTable();
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[0]));
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1]));
+    ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[2]));
+    ASSERT_OK(static_cast<DBImpl*>(db2)->TEST_WaitForFlushMemTable());
   };
 
   // Trigger a flush on cf2
@@ -595,7 +598,7 @@ TEST_F(DBTest2, SharedWriteBufferLimitAcrossDB) {
 
   ASSERT_OK(Put(2, Key(1), DummyString(1), wo));
   wait_flush();
-  static_cast<DBImpl*>(db2)->TEST_WaitForFlushMemTable();
+  ASSERT_OK(static_cast<DBImpl*>(db2)->TEST_WaitForFlushMemTable());
   {
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default") +
                   GetNumberOfSstFilesForColumnFamily(db_, "cf1") +
@@ -626,7 +629,7 @@ TEST_F(DBTest2, SharedWriteBufferLimitAcrossDB) {
   wait_flush();
   ASSERT_OK(db2->Put(wo, Key(1), DummyString(1)));
   wait_flush();
-  static_cast<DBImpl*>(db2)->TEST_WaitForFlushMemTable();
+  ASSERT_OK(static_cast<DBImpl*>(db2)->TEST_WaitForFlushMemTable());
   {
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
               static_cast<uint64_t>(1));
@@ -750,9 +753,9 @@ TEST_F(DBTest2, WalFilterTest) {
     for (size_t i = 0; i < batch_keys.size(); i++) {
       WriteBatch batch;
       for (size_t j = 0; j < batch_keys[i].size(); j++) {
-        batch.Put(handles_[0], batch_keys[i][j], DummyString(1024));
+        ASSERT_OK(batch.Put(handles_[0], batch_keys[i][j], DummyString(1024)));
       }
-      dbfull()->Write(WriteOptions(), &batch);
+      ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
     }
 
     WalFilter::WalProcessingOption wal_processing_option =
@@ -771,14 +774,14 @@ TEST_F(DBTest2, WalFilterTest) {
       TryReopenWithColumnFamilies({ "default", "pikachu" }, options);
     if (wal_processing_option ==
       WalFilter::WalProcessingOption::kCorruptedRecord) {
-      assert(!status.ok());
+      ASSERT_NOK(status);
       // In case of corruption we can turn off paranoid_checks to reopen
       // databse
       options.paranoid_checks = false;
       ReopenWithColumnFamilies({ "default", "pikachu" }, options);
     }
     else {
-      assert(status.ok());
+      ASSERT_OK(status);
     }
 
     // Compute which keys we expect to be found
@@ -835,7 +838,7 @@ TEST_F(DBTest2, WalFilterTest) {
       break;
     }
     default:
-      assert(false);  // unhandled case
+      FAIL();  // unhandled case
     }
 
     bool checked_after_reopen = false;
@@ -878,7 +881,7 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
       num_keys_added_(0) {}
     void Put(const Slice& key, const Slice& value) override {
       if (num_keys_added_ < num_keys_to_add_in_new_batch_) {
-        new_write_batch_->Put(key, value);
+        ASSERT_OK(new_write_batch_->Put(key, value));
         ++num_keys_added_;
       }
     }
@@ -905,8 +908,12 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
                                   bool* batch_changed) const override {
       if (current_record_index_ >= change_records_from_index_) {
         ChangeBatchHandler handler(new_batch, num_keys_to_add_in_new_batch_);
-        batch.Iterate(&handler);
-        *batch_changed = true;
+        Status s = batch.Iterate(&handler);
+        if (s.ok()) {
+          *batch_changed = true;
+        } else {
+          assert(false);
+        }
       }
 
       // Filter is passed as a const object for RocksDB to not modify the
@@ -938,9 +945,9 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatch) {
   for (size_t i = 0; i < batch_keys.size(); i++) {
     WriteBatch batch;
     for (size_t j = 0; j < batch_keys[i].size(); j++) {
-      batch.Put(handles_[0], batch_keys[i][j], DummyString(1024));
+      ASSERT_OK(batch.Put(handles_[0], batch_keys[i][j], DummyString(1024)));
     }
-    dbfull()->Write(WriteOptions(), &batch);
+    ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
   }
 
   // Create a test filter that would apply wal_processing_option at the first
@@ -999,8 +1006,12 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatchExtraKeys) {
    WalProcessingOption LogRecord(const WriteBatch& batch, WriteBatch* new_batch,
                                  bool* batch_changed) const override {
      *new_batch = batch;
-     new_batch->Put("key_extra", "value_extra");
-     *batch_changed = true;
+     Status s = new_batch->Put("key_extra", "value_extra");
+     if (s.ok()) {
+       *batch_changed = true;
+     } else {
+       assert(false);
+     }
      return WalProcessingOption::kContinueProcessing;
    }
 
@@ -1026,9 +1037,9 @@ TEST_F(DBTest2, WalFilterTestWithChangeBatchExtraKeys) {
   for (size_t i = 0; i < batch_keys.size(); i++) {
     WriteBatch batch;
     for (size_t j = 0; j < batch_keys[i].size(); j++) {
-      batch.Put(handles_[0], batch_keys[i][j], DummyString(1024));
+      ASSERT_OK(batch.Put(handles_[0], batch_keys[i][j], DummyString(1024)));
     }
-    dbfull()->Write(WriteOptions(), &batch);
+    ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
   }
 
   // Create a test filter that would add extra keys
@@ -1111,7 +1122,11 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
         }
       } handler(log_number, cf_log_number_map_, cf_wal_keys_);
 
-      batch.Iterate(&handler);
+      Status s = batch.Iterate(&handler);
+      if (!s.ok()) {
+        // TODO(AR) is this ok?
+        return WalProcessingOption::kCorruptedRecord;
+      }
 
       return WalProcessingOption::kContinueProcessing;
    }
@@ -1146,14 +1161,16 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
   for (size_t i = 0; i < batch_keys_pre_flush.size(); i++) {
     WriteBatch batch;
     for (size_t j = 0; j < batch_keys_pre_flush[i].size(); j++) {
-      batch.Put(handles_[0], batch_keys_pre_flush[i][j], DummyString(1024));
-      batch.Put(handles_[1], batch_keys_pre_flush[i][j], DummyString(1024));
+      ASSERT_OK(batch.Put(handles_[0], batch_keys_pre_flush[i][j],
+                          DummyString(1024)));
+      ASSERT_OK(batch.Put(handles_[1], batch_keys_pre_flush[i][j],
+                          DummyString(1024)));
     }
-    dbfull()->Write(WriteOptions(), &batch);
+    ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
   }
 
   //Flush default column-family
-  db_->Flush(FlushOptions(), handles_[0]);
+  ASSERT_OK(db_->Flush(FlushOptions(), handles_[0]));
 
   // Do some more writes
   std::vector<std::vector<std::string>> batch_keys_post_flush(3);
@@ -1169,10 +1186,12 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
   for (size_t i = 0; i < batch_keys_post_flush.size(); i++) {
     WriteBatch batch;
     for (size_t j = 0; j < batch_keys_post_flush[i].size(); j++) {
-      batch.Put(handles_[0], batch_keys_post_flush[i][j], DummyString(1024));
-      batch.Put(handles_[1], batch_keys_post_flush[i][j], DummyString(1024));
+      ASSERT_OK(batch.Put(handles_[0], batch_keys_post_flush[i][j],
+                          DummyString(1024)));
+      ASSERT_OK(batch.Put(handles_[1], batch_keys_post_flush[i][j],
+                          DummyString(1024)));
     }
-    dbfull()->Write(WriteOptions(), &batch);
+    ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
   }
 
   // On Recovery we should only find the second batch applicable to default CF
@@ -1199,10 +1218,10 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
     for (size_t j = 0; j < batch_keys_post_flush[i].size(); j++) {
       Slice key_from_the_log(keys_cf[index++]);
       Slice batch_key(batch_keys_post_flush[i][j]);
-      ASSERT_TRUE(key_from_the_log.compare(batch_key) == 0);
+      ASSERT_EQ(key_from_the_log.compare(batch_key), 0);
     }
   }
-  ASSERT_TRUE(index == keys_cf.size());
+  ASSERT_EQ(index, keys_cf.size());
 
   index = 0;
   keys_cf = cf_wal_keys[name_id_map["pikachu"]];
@@ -1211,7 +1230,7 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
     for (size_t j = 0; j < batch_keys_pre_flush[i].size(); j++) {
       Slice key_from_the_log(keys_cf[index++]);
       Slice batch_key(batch_keys_pre_flush[i][j]);
-      ASSERT_TRUE(key_from_the_log.compare(batch_key) == 0);
+      ASSERT_EQ(key_from_the_log.compare(batch_key), 0);
     }
   }
 
@@ -1219,10 +1238,10 @@ TEST_F(DBTest2, WalFilterTestWithColumnFamilies) {
     for (size_t j = 0; j < batch_keys_post_flush[i].size(); j++) {
       Slice key_from_the_log(keys_cf[index++]);
       Slice batch_key(batch_keys_post_flush[i][j]);
-      ASSERT_TRUE(key_from_the_log.compare(batch_key) == 0);
+      ASSERT_EQ(key_from_the_log.compare(batch_key), 0);
     }
   }
-  ASSERT_TRUE(index == keys_cf.size());
+  ASSERT_EQ(index, keys_cf.size());
 }
 
 TEST_F(DBTest2, PresetCompressionDict) {
@@ -1319,11 +1338,11 @@ TEST_F(DBTest2, PresetCompressionDict) {
           ASSERT_OK(Put(1, Key(static_cast<int>(key_num)),
                         seq_datas[(key_num / 10) % 10]));
         }
-        dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
+        ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1]));
         ASSERT_EQ(j + 1, NumTableFilesAtLevel(0, 1));
       }
-      dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1],
-                                  true /* disallow_trivial_move */);
+      ASSERT_OK(dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1],
+                                            true /* disallow_trivial_move */));
       ASSERT_EQ(0, NumTableFilesAtLevel(0, 1));
       ASSERT_GT(NumTableFilesAtLevel(1, 1), 0);
 
@@ -1893,7 +1912,7 @@ TEST_F(DBTest2, CompressionOptions) {
           ASSERT_OK(Put(key, value));
         }
         ASSERT_OK(Flush());
-        dbfull()->TEST_WaitForCompact();
+        ASSERT_OK(dbfull()->TEST_WaitForCompact());
       }
 
       // Make sure that we wrote enough to check all 7 levels
@@ -1908,6 +1927,7 @@ TEST_F(DBTest2, CompressionOptions) {
         ASSERT_EQ(key_value_written[key], value);
         key_value_written.erase(key);
       }
+      ASSERT_OK(db_iter->status());
       ASSERT_EQ(0, key_value_written.size());
     }
   }
@@ -1989,7 +2009,7 @@ TEST_F(DBTest2, CompactionStall) {
   // Hold NotifyOnCompactionCompleted in the unlock mutex section
   TEST_SYNC_POINT("DBTest2::CompactionStall:3");
 
-  dbfull()->TEST_WaitForCompact();
+  ASSERT_OK(dbfull()->TEST_WaitForCompact());
   ASSERT_LT(NumTableFilesAtLevel(0),
             options.level0_file_num_compaction_trigger);
   ASSERT_GT(listener->compacted_files_cnt_.load(),
@@ -2010,8 +2030,8 @@ TEST_F(DBTest2, FirstSnapshotTest) {
   // This snapshot will have sequence number 0 what is expected behaviour.
   const Snapshot* s1 = db_->GetSnapshot();
 
-  Put(1, "k1", std::string(100000, 'x'));  // Fill memtable
-  Put(1, "k2", std::string(100000, 'y'));  // Trigger flush
+  ASSERT_OK(Put(1, "k1", std::string(100000, 'x')));  // Fill memtable
+  ASSERT_OK(Put(1, "k2", std::string(100000, 'y')));  // Trigger flush
 
   db_->ReleaseSnapshot(s1);
 }
@@ -2024,17 +2044,17 @@ TEST_F(DBTest2, DuplicateSnapshot) {
   DBImpl* dbi = static_cast_with_check<DBImpl>(db_);
   SequenceNumber oldest_ww_snap, first_ww_snap;
 
-  Put("k", "v");  // inc seq
+  ASSERT_OK(Put("k", "v"));  // inc seq
   snapshots.push_back(db_->GetSnapshot());
   snapshots.push_back(db_->GetSnapshot());
-  Put("k", "v");  // inc seq
+  ASSERT_OK(Put("k", "v"));  // inc seq
   snapshots.push_back(db_->GetSnapshot());
   snapshots.push_back(dbi->GetSnapshotForWriteConflictBoundary());
   first_ww_snap = snapshots.back()->GetSequenceNumber();
-  Put("k", "v");  // inc seq
+  ASSERT_OK(Put("k", "v"));  // inc seq
   snapshots.push_back(dbi->GetSnapshotForWriteConflictBoundary());
   snapshots.push_back(db_->GetSnapshot());
-  Put("k", "v");  // inc seq
+  ASSERT_OK(Put("k", "v"));  // inc seq
   snapshots.push_back(db_->GetSnapshot());
 
   {
@@ -2074,19 +2094,19 @@ class PinL0IndexAndFilterBlocksTest
     options->table_factory.reset(NewBlockBasedTableFactory(table_options));
     CreateAndReopenWithCF({"pikachu"}, *options);
 
-    Put(1, "a", "begin");
-    Put(1, "z", "end");
+    ASSERT_OK(Put(1, "a", "begin"));
+    ASSERT_OK(Put(1, "z", "end"));
     ASSERT_OK(Flush(1));
     // move this table to L1
-    dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1]);
+    ASSERT_OK(dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1]));
 
     // reset block cache
     table_options.block_cache = NewLRUCache(64 * 1024);
     options->table_factory.reset(NewBlockBasedTableFactory(table_options));
     TryReopenWithColumnFamilies({"default", "pikachu"}, *options);
     // create new table at L0
-    Put(1, "a2", "begin2");
-    Put(1, "z2", "end2");
+    ASSERT_OK(Put(1, "a2", "begin2"));
+    ASSERT_OK(Put(1, "z2", "end2"));
     ASSERT_OK(Flush(1));
 
     if (close_afterwards) {
@@ -2130,7 +2150,7 @@ TEST_P(PinL0IndexAndFilterBlocksTest,
 
   std::string value;
   // Miss and hit count should remain the same, they're all pinned.
-  db_->KeyMayExist(ReadOptions(), handles_[1], "key", &value);
+  ASSERT_TRUE(db_->KeyMayExist(ReadOptions(), handles_[1], "key", &value));
   ASSERT_EQ(1, TestGetTickerCount(options, BLOCK_CACHE_FILTER_MISS));
   ASSERT_EQ(0, TestGetTickerCount(options, BLOCK_CACHE_FILTER_HIT));
   ASSERT_EQ(1, TestGetTickerCount(options, BLOCK_CACHE_INDEX_MISS));
@@ -2258,7 +2278,7 @@ TEST_P(PinL0IndexAndFilterBlocksTest, DisablePrefetchingNonL0IndexAndFilter) {
   // cache read for both of index and filter. If prefetch doesn't explicitly
   // happen, it will happen when verifying the file.
   Compact(1, "a", "zzzzz");
-  dbfull()->TEST_WaitForCompact();
+  ASSERT_OK(dbfull()->TEST_WaitForCompact());
 
   if (!disallow_preload_) {
     ASSERT_EQ(fm + 3, TestGetTickerCount(options, BLOCK_CACHE_FILTER_MISS));
@@ -2329,10 +2349,10 @@ TEST_F(DBTest2, MaxCompactionBytesTest) {
   GenerateNewRandomFile(&rnd);
   // Add three more small files that overlap with the previous file
   for (int i = 0; i < 3; i++) {
-    Put("a", "z");
+    ASSERT_OK(Put("a", "z"));
     ASSERT_OK(Flush());
   }
-  dbfull()->TEST_WaitForCompact();
+  ASSERT_OK(dbfull()->TEST_WaitForCompact());
 
   // Output files to L1 are cut to three pieces, according to
   // options.max_compaction_bytes
@@ -2493,6 +2513,7 @@ TEST_F(DBTest2, TestPerfContextIterCpuTime) {
   ASSERT_EQ(0, get_perf_context()->iter_next_cpu_nanos);
   iter->Prev();
   ASSERT_TRUE(iter->Valid());
+  ASSERT_OK(iter->status());
   ASSERT_EQ("v0", iter->value().ToString());
   ASSERT_EQ(0, get_perf_context()->iter_prev_cpu_nanos);
   ASSERT_EQ(0, env_->now_cpu_count_.load());
@@ -2529,6 +2550,7 @@ TEST_F(DBTest2, TestPerfContextIterCpuTime) {
   ASSERT_LT(get_perf_context()->iter_next_cpu_nanos, kDummyAddonNanos);
   iter->Prev();
   ASSERT_TRUE(iter->Valid());
+  ASSERT_OK(iter->status());
   ASSERT_EQ("v0", iter->value().ToString());
   ASSERT_GT(get_perf_context()->iter_prev_cpu_nanos, 0);
   ASSERT_LT(get_perf_context()->iter_prev_cpu_nanos, kDummyAddonNanos);
@@ -2726,6 +2748,7 @@ TEST_F(DBTest2, ReadAmpBitmap) {
     for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
       ASSERT_EQ(iter->value().ToString(), Get(iter->key().ToString()));
     }
+    ASSERT_OK(iter->status());
     delete iter;
 
     // Read amp is on average 100% since we read all what we loaded in memory
@@ -3045,10 +3068,12 @@ TEST_F(DBTest2, PausingManualCompaction1) {
   }
 
   // OK, now trigger a manual compaction
-  dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(CompactRangeOptions(), nullptr, nullptr)
+                  .IsManualCompactionPaused());
 
   // Wait for compactions to get scheduled and stopped
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   // Get file names after compaction is stopped
   files_meta.clear();
@@ -3063,10 +3088,12 @@ TEST_F(DBTest2, PausingManualCompaction1) {
 
   manual_compactions_paused = 0;
   // Now make sure CompactFiles also not run
-  dbfull()->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(),
-                         files_before_compact, 0);
+  ASSERT_TRUE(dbfull()
+                  ->CompactFiles(ROCKSDB_NAMESPACE::CompactionOptions(),
+                                 files_before_compact, 0)
+                  .IsManualCompactionPaused());
   // Wait for manual compaction to get scheduled and finish
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   files_meta.clear();
   files_after_compact.clear();
@@ -3119,7 +3146,7 @@ TEST_F(DBTest2, PausingManualCompaction3) {
         for (int k = 0; k < 1000; k++) {
           ASSERT_OK(Put(Key(k + j * 1000), rnd.RandomString(50)));
         }
-        Flush();
+        ASSERT_OK(Flush());
       }
 
       for (int l = 1; l < options.num_levels - i; l++) {
@@ -3140,8 +3167,10 @@ TEST_F(DBTest2, PausingManualCompaction3) {
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
 
   dbfull()->DisableManualCompaction();
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
   // As manual compaction disabled, not even reach sync point
   ASSERT_EQ(run_manual_compactions, 0);
 #ifndef ROCKSDB_LITE
@@ -3151,8 +3180,8 @@ TEST_F(DBTest2, PausingManualCompaction3) {
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
       "CompactionJob::Run():PausingManualCompaction:1");
   dbfull()->EnableManualCompaction();
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->CompactRange(compact_options, nullptr, nullptr));
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
@@ -3173,7 +3202,7 @@ TEST_F(DBTest2, PausingManualCompaction4) {
         for (int k = 0; k < 1000; k++) {
           ASSERT_OK(Put(Key(k + j * 1000), rnd.RandomString(50)));
         }
-        Flush();
+        ASSERT_OK(Flush());
       }
 
       for (int l = 1; l < options.num_levels - i; l++) {
@@ -3197,8 +3226,10 @@ TEST_F(DBTest2, PausingManualCompaction4) {
       });
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
 
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
   ASSERT_EQ(run_manual_compactions, 1);
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("2,3,4,5,6,7,8", FilesPerLevel());
@@ -3207,8 +3238,8 @@ TEST_F(DBTest2, PausingManualCompaction4) {
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
       "CompactionJob::Run():PausingManualCompaction:2");
   dbfull()->EnableManualCompaction();
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->CompactRange(compact_options, nullptr, nullptr));
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
@@ -3233,7 +3264,7 @@ TEST_F(DBTest2, CancelManualCompaction1) {
         for (int k = 0; k < 1000; k++) {
           ASSERT_OK(Put(Key(k + j * 1000), rnd.RandomString(50)));
         }
-        Flush();
+        ASSERT_OK(Flush());
       }
 
       for (int l = 1; l < options.num_levels - i; l++) {
@@ -3261,8 +3292,10 @@ TEST_F(DBTest2, CancelManualCompaction1) {
       "DBImpl::RunManualCompaction()::1",
       [&](void* /*arg*/) { ++compactions_run; });
 
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   // Since compactions are disabled, we shouldn't start compacting.
   // E.g. we should call the compaction function exactly one time.
@@ -3285,8 +3318,10 @@ TEST_F(DBTest2, CancelManualCompaction1) {
       });
 
   compact_options.canceled->store(false, std::memory_order_release);
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   ASSERT_EQ(compactions_run, 3);
 
@@ -3297,8 +3332,8 @@ TEST_F(DBTest2, CancelManualCompaction1) {
 
   // Compactions should work again if we re-enable them..
   compact_options.canceled->store(false, std::memory_order_relaxed);
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->CompactRange(compact_options, nullptr, nullptr));
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
@@ -3324,7 +3359,7 @@ TEST_F(DBTest2, CancelManualCompaction2) {
         for (int k = 0; k < 1000; k++) {
           ASSERT_OK(Put(Key(k + j * 1000), rnd.RandomString(50)));
         }
-        Flush();
+        ASSERT_OK(Flush());
       }
 
       for (int l = 1; l < options.num_levels - i; l++) {
@@ -3363,8 +3398,10 @@ TEST_F(DBTest2, CancelManualCompaction2) {
       });
 
   compact_options.canceled->store(false, std::memory_order_release);
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   // NOTE: as we set compact_options.max_subcompacitons = 1, and store true to
   // the canceled variable from the single compacting thread (via callback),
@@ -3381,8 +3418,8 @@ TEST_F(DBTest2, CancelManualCompaction2) {
 
   // Compactions should work again if we re-enable them..
   compact_options.canceled->store(false, std::memory_order_relaxed);
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->CompactRange(compact_options, nullptr, nullptr));
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
@@ -3434,7 +3471,7 @@ TEST_F(DBTest2, CancelManualCompactionWithListener) {
     for (int j = 0; j < 10; j++) {
       ASSERT_OK(Put(Key(i + j * 10), rnd.RandomString(50)));
     }
-    Flush();
+    ASSERT_OK(Flush());
   }
 
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
@@ -3455,8 +3492,10 @@ TEST_F(DBTest2, CancelManualCompactionWithListener) {
   listener->subcode_ = Status::SubCode::kManualCompactionPaused;
 
   compact_options.canceled->store(false, std::memory_order_release);
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   ASSERT_GT(listener->num_compaction_started_, 0);
   ASSERT_EQ(listener->num_compaction_started_, listener->num_compaction_ended_);
@@ -3467,8 +3506,10 @@ TEST_F(DBTest2, CancelManualCompactionWithListener) {
 
   // Case II: 1 DisableManualCompaction, 2 Notify begin compaction (return
   // without notifying), 3 Notify compaction end (return without notifying).
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_TRUE(dbfull()
+                  ->CompactRange(compact_options, nullptr, nullptr)
+                  .IsManualCompactionPaused());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   ASSERT_EQ(listener->num_compaction_started_, 0);
   ASSERT_EQ(listener->num_compaction_started_, listener->num_compaction_ended_);
@@ -3489,8 +3530,8 @@ TEST_F(DBTest2, CancelManualCompactionWithListener) {
   listener->subcode_ = Status::SubCode::kNone;
 
   compact_options.canceled->store(false, std::memory_order_release);
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(dbfull()->CompactRange(compact_options, nullptr, nullptr));
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 
   ASSERT_GT(listener->num_compaction_started_, 0);
   ASSERT_EQ(listener->num_compaction_started_, listener->num_compaction_ended_);
@@ -3568,7 +3609,7 @@ TEST_F(DBTest2, OptimizeForPointLookup) {
 
   ASSERT_OK(Put("foo", "v1"));
   ASSERT_EQ("v1", Get("foo"));
-  Flush();
+  ASSERT_OK(Flush());
   ASSERT_EQ("v1", Get("foo"));
 }
 
@@ -3594,7 +3635,7 @@ TEST_F(DBTest2, OptimizeForSmallDB) {
   ASSERT_NE(0, cache->GetUsage());
 
   ASSERT_EQ("v1", Get("foo"));
-  Flush();
+  ASSERT_OK(Flush());
 
   size_t prev_size = cache->GetUsage();
   // Remember block cache size, so that we can find that
@@ -3621,7 +3662,7 @@ TEST_F(DBTest2, IterRaceFlush1) {
   ROCKSDB_NAMESPACE::port::Thread t1([&] {
     TEST_SYNC_POINT("DBTest2::IterRaceFlush:1");
     ASSERT_OK(Put("foo", "v2"));
-    Flush();
+    ASSERT_OK(Flush());
     TEST_SYNC_POINT("DBTest2::IterRaceFlush:2");
   });
 
@@ -3631,6 +3672,7 @@ TEST_F(DBTest2, IterRaceFlush1) {
     std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
     it->Seek("foo");
     ASSERT_TRUE(it->Valid());
+    ASSERT_OK(it->status());
     ASSERT_EQ("foo", it->key().ToString());
   }
 
@@ -3650,7 +3692,7 @@ TEST_F(DBTest2, IterRaceFlush2) {
   ROCKSDB_NAMESPACE::port::Thread t1([&] {
     TEST_SYNC_POINT("DBTest2::IterRaceFlush2:1");
     ASSERT_OK(Put("foo", "v2"));
-    Flush();
+    ASSERT_OK(Flush());
     TEST_SYNC_POINT("DBTest2::IterRaceFlush2:2");
   });
 
@@ -3660,6 +3702,7 @@ TEST_F(DBTest2, IterRaceFlush2) {
     std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
     it->Seek("foo");
     ASSERT_TRUE(it->Valid());
+    ASSERT_OK(it->status());
     ASSERT_EQ("foo", it->key().ToString());
   }
 
@@ -3679,7 +3722,7 @@ TEST_F(DBTest2, IterRefreshRaceFlush) {
   ROCKSDB_NAMESPACE::port::Thread t1([&] {
     TEST_SYNC_POINT("DBTest2::IterRefreshRaceFlush:1");
     ASSERT_OK(Put("foo", "v2"));
-    Flush();
+    ASSERT_OK(Flush());
     TEST_SYNC_POINT("DBTest2::IterRefreshRaceFlush:2");
   });
 
@@ -3687,9 +3730,11 @@ TEST_F(DBTest2, IterRefreshRaceFlush) {
   // "v1" or "v2".
   {
     std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions()));
-    it->Refresh();
+    ASSERT_OK(it->status());
+    ASSERT_OK(it->Refresh());
     it->Seek("foo");
     ASSERT_TRUE(it->Valid());
+    ASSERT_OK(it->status());
     ASSERT_EQ("foo", it->key().ToString());
   }
 
@@ -3709,7 +3754,7 @@ TEST_F(DBTest2, GetRaceFlush1) {
   ROCKSDB_NAMESPACE::port::Thread t1([&] {
     TEST_SYNC_POINT("DBTest2::GetRaceFlush:1");
     ASSERT_OK(Put("foo", "v2"));
-    Flush();
+    ASSERT_OK(Flush());
     TEST_SYNC_POINT("DBTest2::GetRaceFlush:2");
   });
 
@@ -3732,7 +3777,7 @@ TEST_F(DBTest2, GetRaceFlush2) {
   port::Thread t1([&] {
     TEST_SYNC_POINT("DBTest2::GetRaceFlush:1");
     ASSERT_OK(Put("foo", "v2"));
-    Flush();
+    ASSERT_OK(Flush());
     TEST_SYNC_POINT("DBTest2::GetRaceFlush:2");
   });
 
@@ -3805,6 +3850,7 @@ TEST_F(DBTest2, MemtableOnlyIterator) {
   ASSERT_EQ("second", value);
   // nothing should be returned using memtable-only iterator after flushing.
   it = db_->NewIterator(ropt, handles_[1]);
+  ASSERT_OK(it->status());
   count = 0;
   for (it->SeekToFirst(); it->Valid(); it->Next()) {
     ASSERT_TRUE(it->Valid());
@@ -3812,11 +3858,13 @@ TEST_F(DBTest2, MemtableOnlyIterator) {
   }
   ASSERT_TRUE(!it->Valid());
   ASSERT_EQ(0, count);
+  ASSERT_OK(it->status());
   delete it;
 
   // Add a key to memtable
   ASSERT_OK(Put(1, "foobar", "third"));
   it = db_->NewIterator(ropt, handles_[1]);
+  ASSERT_OK(it->status());
   count = 0;
   for (it->SeekToFirst(); it->Valid(); it->Next()) {
     ASSERT_TRUE(it->Valid());
@@ -3826,6 +3874,7 @@ TEST_F(DBTest2, MemtableOnlyIterator) {
   }
   ASSERT_TRUE(!it->Valid());
   ASSERT_EQ(1, count);
+  ASSERT_OK(it->status());
   delete it;
 }
 
@@ -3854,28 +3903,28 @@ TEST_F(DBTest2, LowPriWrite) {
   WriteOptions wo;
   for (int i = 0; i < 6; i++) {
     wo.low_pri = false;
-    Put("", "", wo);
+    ASSERT_OK(Put("", "", wo));
     wo.low_pri = true;
-    Put("", "", wo);
-    Flush();
+    ASSERT_OK(Put("", "", wo));
+    ASSERT_OK(Flush());
   }
   ASSERT_EQ(0, rate_limit_count.load());
   wo.low_pri = true;
-  Put("", "", wo);
+  ASSERT_OK(Put("", "", wo));
   ASSERT_EQ(1, rate_limit_count.load());
   wo.low_pri = false;
-  Put("", "", wo);
+  ASSERT_OK(Put("", "", wo));
   ASSERT_EQ(1, rate_limit_count.load());
 
   TEST_SYNC_POINT("DBTest.LowPriWrite:0");
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
 
-  dbfull()->TEST_WaitForCompact();
+  ASSERT_OK(dbfull()->TEST_WaitForCompact());
   wo.low_pri = true;
-  Put("", "", wo);
+  ASSERT_OK(Put("", "", wo));
   ASSERT_EQ(1, rate_limit_count.load());
   wo.low_pri = false;
-  Put("", "", wo);
+  ASSERT_OK(Put("", "", wo));
   ASSERT_EQ(1, rate_limit_count.load());
 }
 
@@ -3915,10 +3964,10 @@ TEST_F(DBTest2, RateLimitedCompactionReads) {
       for (int j = 0; j <= kNumKeysPerFile; ++j) {
         ASSERT_OK(Put(Key(j), DummyString(kBytesPerKey)));
       }
-      dbfull()->TEST_WaitForFlushMemTable();
+      ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
       ASSERT_EQ(i + 1, NumTableFilesAtLevel(0));
     }
-    dbfull()->TEST_WaitForCompact();
+    ASSERT_OK(dbfull()->TEST_WaitForCompact());
     ASSERT_EQ(0, NumTableFilesAtLevel(0));
 
     ASSERT_EQ(0, options.rate_limiter->GetTotalBytesThrough(Env::IO_HIGH));
@@ -3937,6 +3986,7 @@ TEST_F(DBTest2, RateLimitedCompactionReads) {
                             direct_io_extra));
 
     Iterator* iter = db_->NewIterator(ReadOptions());
+    ASSERT_OK(iter->status());
     for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
       ASSERT_EQ(iter->value().ToString(), DummyString(kBytesPerKey));
     }
@@ -3957,8 +4007,8 @@ TEST_F(DBTest2, ReduceLevel) {
   options.disable_auto_compactions = true;
   options.num_levels = 7;
   Reopen(options);
-  Put("foo", "bar");
-  Flush();
+  ASSERT_OK(Put("foo", "bar"));
+  ASSERT_OK(Flush());
   MoveFilesToLevel(6);
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,0,0,0,0,0,1", FilesPerLevel());
@@ -3966,7 +4016,7 @@ TEST_F(DBTest2, ReduceLevel) {
   CompactRangeOptions compact_options;
   compact_options.change_level = true;
   compact_options.target_level = 1;
-  dbfull()->CompactRange(compact_options, nullptr, nullptr);
+  ASSERT_OK(dbfull()->CompactRange(compact_options, nullptr, nullptr));
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,1", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
@@ -3995,35 +4045,35 @@ TEST_F(DBTest2, ReadCallbackTest) {
   // the DB instead of assuming what seq the DB used.
   int i = 1;
   for (; i < 10; i++) {
-    Put(key, value + std::to_string(i));
+    ASSERT_OK(Put(key, value + std::to_string(i)));
     // Take a snapshot to avoid the value being removed during compaction
     auto snapshot = dbfull()->GetSnapshot();
     snapshots.push_back(snapshot);
   }
-  Flush();
+  ASSERT_OK(Flush());
   for (; i < 20; i++) {
-    Put(key, value + std::to_string(i));
+    ASSERT_OK(Put(key, value + std::to_string(i)));
     // Take a snapshot to avoid the value being removed during compaction
     auto snapshot = dbfull()->GetSnapshot();
     snapshots.push_back(snapshot);
   }
-  Flush();
+  ASSERT_OK(Flush());
   MoveFilesToLevel(6);
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,0,0,0,0,0,2", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
   for (; i < 30; i++) {
-    Put(key, value + std::to_string(i));
+    ASSERT_OK(Put(key, value + std::to_string(i)));
     auto snapshot = dbfull()->GetSnapshot();
     snapshots.push_back(snapshot);
   }
-  Flush();
+  ASSERT_OK(Flush());
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("1,0,0,0,0,0,2", FilesPerLevel());
 #endif  // !ROCKSDB_LITE
   // And also add some values to the memtable
   for (; i < 40; i++) {
-    Put(key, value + std::to_string(i));
+    ASSERT_OK(Put(key, value + std::to_string(i)));
     auto snapshot = dbfull()->GetSnapshot();
     snapshots.push_back(snapshot);
   }
@@ -4096,21 +4146,21 @@ TEST_F(DBTest2, LiveFilesOmitObsoleteFiles) {
       [&](void* /*arg*/) { env_->SleepForMicroseconds(1000000); });
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
 
-  Put("key", "val");
+  ASSERT_OK(Put("key", "val"));
   FlushOptions flush_opts;
   flush_opts.wait = false;
   db_->Flush(flush_opts);
   TEST_SYNC_POINT("DBTest2::LiveFilesOmitObsoleteFiles:FlushTriggered");
 
-  db_->DisableFileDeletions();
+  ASSERT_OK(db_->DisableFileDeletions());
   VectorLogPtr log_files;
-  db_->GetSortedWalFiles(log_files);
+  ASSERT_OK(db_->GetSortedWalFiles(log_files));
   TEST_SYNC_POINT("DBTest2::LiveFilesOmitObsoleteFiles:LiveFilesCaptured");
   for (const auto& log_file : log_files) {
     ASSERT_OK(env_->FileExists(LogFileName(dbname_, log_file->LogNumber())));
   }
 
-  db_->EnableFileDeletions();
+  ASSERT_OK(db_->EnableFileDeletions());
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
 }
 
@@ -4221,6 +4271,7 @@ TEST_F(DBTest2, TraceAndReplay) {
   single_iter = db_->NewIterator(ro);
   single_iter->Seek("f");
   single_iter->SeekForPrev("g");
+  ASSERT_OK(single_iter->status());
   delete single_iter;
 
   ASSERT_EQ("1", Get(0, "a"));
@@ -4232,8 +4283,8 @@ TEST_F(DBTest2, TraceAndReplay) {
 
   ASSERT_OK(db_->EndTrace());
   // These should not get into the trace file as it is after EndTrace.
-  Put("hello", "world");
-  Merge("foo", "bar");
+  ASSERT_OK(Put("hello", "world"));
+  ASSERT_OK(Merge("foo", "bar"));
 
   // Open another db, replay, and verify the data
   std::string value;
@@ -4359,8 +4410,8 @@ TEST_F(DBTest2, TraceAndManualReplay) {
 
   ASSERT_OK(db_->EndTrace());
   // These should not get into the trace file as it is after EndTrace.
-  Put("hello", "world");
-  Merge("foo", "bar");
+  ASSERT_OK(Put("hello", "world"));
+  ASSERT_OK(Merge("foo", "bar"));
 
   // Open another db, replay, and verify the data
   std::string value;
@@ -4441,8 +4492,8 @@ TEST_F(DBTest2, TraceAndManualReplay) {
   uint64_t fake_ts = 1U;
   // Write
   batch.Clear();
-  batch.Put("trace-record-write1", "write1");
-  batch.Put("trace-record-write2", "write2");
+  ASSERT_OK(batch.Put("trace-record-write1", "write1"));
+  ASSERT_OK(batch.Put("trace-record-write2", "write2"));
   record.reset(new WriteQueryTraceRecord(batch.Data(), fake_ts++));
   ASSERT_OK(replayer->Execute(std::move(record)));
   ASSERT_OK(db2->Get(ro, handles[0], "trace-record-write1", &value));
@@ -4720,8 +4771,8 @@ TEST_F(DBTest2, TraceWithFilter) {
 
   ASSERT_OK(db_->EndTrace());
   // These should not get into the trace file as it is after EndTrace.
-  Put("hello", "world");
-  Merge("foo", "bar");
+  ASSERT_OK(Put("hello", "world"));
+  ASSERT_OK(Merge("foo", "bar"));
 
   // Open another db, replay, and verify the data
   std::string value;
@@ -4874,9 +4925,9 @@ TEST_F(DBTest2, PinnableSliceAndMmapReads) {
   ASSERT_FALSE(pinned_value.IsPinned());
   ASSERT_EQ(pinned_value.ToString(), "bar");
 
-  dbfull()->TEST_CompactRange(0 /* level */, nullptr /* begin */,
-                              nullptr /* end */, nullptr /* column_family */,
-                              true /* disallow_trivial_move */);
+  ASSERT_OK(dbfull()->TEST_CompactRange(
+      0 /* level */, nullptr /* begin */, nullptr /* end */,
+      nullptr /* column_family */, true /* disallow_trivial_move */));
 
   // Ensure pinned_value doesn't rely on memory munmap'd by the above
   // compaction. It crashes if it does.
@@ -4920,10 +4971,10 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
 
   // Since v is the size of a block, each key should take a block
   // of 400+ bytes.
-  Put("1", v);
-  Put("3", v);
-  Put("5", v);
-  Put("7", v);
+  ASSERT_OK(Put("1", v));
+  ASSERT_OK(Put("3", v));
+  ASSERT_OK(Put("5", v));
+  ASSERT_OK(Put("7", v));
   ASSERT_OK(Flush());
 
   ASSERT_EQ(0, bbto.block_cache->GetPinnedUsage());
@@ -4952,16 +5003,18 @@ TEST_F(DBTest2, DISABLED_IteratorPinnedMemory) {
     iter->Seek("3");
     ASSERT_TRUE(iter->Valid());
 
+    ASSERT_OK(iter->status());
+
     ASSERT_GT(bbto.block_cache->GetPinnedUsage(), 0);
     ASSERT_LT(bbto.block_cache->GetPinnedUsage(), 800);
   }
   ASSERT_EQ(0, bbto.block_cache->GetPinnedUsage());
 
   // Test compaction case
-  Put("2", v);
-  Put("5", v);
-  Put("6", v);
-  Put("8", v);
+  ASSERT_OK(Put("2", v));
+  ASSERT_OK(Put("5", v));
+  ASSERT_OK(Put("6", v));
+  ASSERT_OK(Put("8", v));
   ASSERT_OK(Flush());
 
   // Clear existing data in block cache
@@ -5020,20 +5073,20 @@ TEST_F(DBTest2, TestBBTTailPrefetch) {
       });
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
 
-  Put("1", "1");
-  Put("9", "1");
-  Flush();
+  ASSERT_OK(Put("1", "1"));
+  ASSERT_OK(Put("9", "1"));
+  ASSERT_OK(Flush());
 
   expected_lower_bound = 0;
   expected_higher_bound = 8 * 1024;
 
-  Put("1", "1");
-  Put("9", "1");
-  Flush();
+  ASSERT_OK(Put("1", "1"));
+  ASSERT_OK(Put("9", "1"));
+  ASSERT_OK(Flush());
 
-  Put("1", "1");
-  Put("9", "1");
-  Flush();
+  ASSERT_OK(Put("1", "1"));
+  ASSERT_OK(Put("9", "1"));
+  ASSERT_OK(Flush());
 
   // Full compaction to make sure there is no L0 file after the open.
   ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
@@ -5066,13 +5119,13 @@ TEST_F(DBTest2, TestBBTTailPrefetch) {
   options.max_open_files = -1;
   Reopen(options);
 
-  Put("1", "1");
-  Put("9", "1");
-  Flush();
+  ASSERT_OK(Put("1", "1"));
+  ASSERT_OK(Put("9", "1"));
+  ASSERT_OK(Flush());
 
-  Put("1", "1");
-  Put("9", "1");
-  Flush();
+  ASSERT_OK(Put("1", "1"));
+  ASSERT_OK(Put("9", "1"));
+  ASSERT_OK(Flush());
 
   ASSERT_TRUE(called.load());
   called = false;
@@ -5173,18 +5226,25 @@ TEST_F(DBTest2, TestCompactFiles) {
   GetSstFiles(env_, dbname_, &files);
   ASSERT_EQ(files.size(), 2);
 
-  port::Thread user_thread1(
-      [&]() { db_->CompactFiles(CompactionOptions(), handle, files, 1); });
+  Status user_thread1_status;
+  port::Thread user_thread1([&]() {
+    user_thread1_status =
+        db_->CompactFiles(CompactionOptions(), handle, files, 1);
+  });
 
+  Status user_thread2_status;
   port::Thread user_thread2([&]() {
-    ASSERT_OK(db_->IngestExternalFile(handle, {external_file2},
-                                      IngestExternalFileOptions()));
+    user_thread2_status = db_->IngestExternalFile(handle, {external_file2},
+                                                  IngestExternalFileOptions());
     TEST_SYNC_POINT("TestCompactFiles::IngestExternalFile1");
   });
 
   user_thread1.join();
   user_thread2.join();
 
+  ASSERT_OK(user_thread1_status);
+  ASSERT_OK(user_thread2_status);
+
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
 }
@@ -5276,7 +5336,7 @@ TEST_F(DBTest2, OldStatsInterface) {
   options.statistics = stats;
   Reopen(options);
 
-  Put("foo", "bar");
+  ASSERT_OK(Put("foo", "bar"));
   ASSERT_EQ("bar", Get("foo"));
   ASSERT_OK(Flush());
   ASSERT_EQ("bar", Get("foo"));
@@ -5324,6 +5384,7 @@ TEST_F(DBTest2, PrefixBloomReseek) {
   ASSERT_OK(Put("bbb1", ""));
 
   Iterator* iter = db_->NewIterator(ReadOptions());
+  ASSERT_OK(iter->status());
 
   // Seeking into f1, the iterator will check bloom filter which returns the
   // file iterator ot be invalidate, and the cursor will put into f2, with
@@ -5362,6 +5423,7 @@ TEST_F(DBTest2, PrefixBloomFilteredOut) {
   ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr));
 
   Iterator* iter = db_->NewIterator(ReadOptions());
+  ASSERT_OK(iter->status());
 
   // Bloom filter is filterd out by f1.
   // This is just one of several valid position following the contract.
@@ -5369,6 +5431,7 @@ TEST_F(DBTest2, PrefixBloomFilteredOut) {
   // the behavior of the current implementation. If underlying implementation
   // changes, the test might fail here.
   iter->Seek("bbb1");
+  ASSERT_OK(iter->status());
   ASSERT_FALSE(iter->Valid());
 
   delete iter;
@@ -5515,6 +5578,7 @@ TEST_F(DBTest2, SeekFileRangeDeleteTail) {
     ReadOptions ro;
     ro.total_order_seek = true;
     std::unique_ptr<Iterator> iter(db_->NewIterator(ro));
+    ASSERT_OK(iter->status());
     iter->Seek("e");
     ASSERT_TRUE(iter->Valid());
     ASSERT_EQ("x", iter->key().ToString());
@@ -5532,6 +5596,7 @@ TEST_F(DBTest2, BackgroundPurgeTest) {
 
   ASSERT_OK(Put("a", "a"));
   Iterator* iter = db_->NewIterator(ReadOptions());
+  ASSERT_OK(iter->status());
   ASSERT_OK(Flush());
   size_t value = options.write_buffer_manager->memory_usage();
   ASSERT_GT(value, base_value);
@@ -5598,14 +5663,14 @@ TEST_F(DBTest2, SameSmallestInSameLevel) {
                                    nullptr));
 
   ASSERT_OK(db_->Merge(WriteOptions(), "key", "5"));
-  Flush();
+  ASSERT_OK(Flush());
   ASSERT_OK(db_->Merge(WriteOptions(), "key", "6"));
-  Flush();
+  ASSERT_OK(Flush());
   ASSERT_OK(db_->Merge(WriteOptions(), "key", "7"));
-  Flush();
+  ASSERT_OK(Flush());
   ASSERT_OK(db_->Merge(WriteOptions(), "key", "8"));
-  Flush();
-  dbfull()->TEST_WaitForCompact(true);
+  ASSERT_OK(Flush());
+  ASSERT_OK(dbfull()->TEST_WaitForCompact(true));
 #ifndef ROCKSDB_LITE
   ASSERT_EQ("0,4,1", FilesPerLevel());
 #endif  // ROCKSDB_LITE
@@ -5614,8 +5679,8 @@ TEST_F(DBTest2, SameSmallestInSameLevel) {
 }
 
 TEST_F(DBTest2, FileConsistencyCheckInOpen) {
-  Put("foo", "bar");
-  Flush();
+  ASSERT_OK(Put("foo", "bar"));
+  ASSERT_OK(Flush());
 
   SyncPoint::GetInstance()->SetCallBack(
       "VersionBuilder::CheckConsistencyBeforeReturn", [&](void* arg) {
@@ -5650,10 +5715,11 @@ TEST_F(DBTest2, BlockBasedTablePrefixIndexSeekForPrev) {
   ASSERT_OK(Put("a1", large_value));
   ASSERT_OK(Put("x1", large_value));
   ASSERT_OK(Put("y1", large_value));
-  Flush();
+  ASSERT_OK(Flush());
 
   {
     std::unique_ptr<Iterator> iterator(db_->NewIterator(ReadOptions()));
+    ASSERT_OK(iterator->status());
     iterator->SeekForPrev("x3");
     ASSERT_TRUE(iterator->Valid());
     ASSERT_EQ("x1", iterator->key().ToString());
@@ -5765,7 +5831,7 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
     ASSERT_OK(Put("xx1", ""));
     ASSERT_OK(Put("xz1", ""));
     ASSERT_OK(Put("zz", ""));
-    Flush();
+    ASSERT_OK(Flush());
 
     // After reopening DB with prefix size 2 => 1, prefix extractor
     // won't take effective unless it won't change results based
@@ -5775,6 +5841,7 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
 
     {
       std::unique_ptr<Iterator> iterator(db_->NewIterator(ReadOptions()));
+      ASSERT_OK(iterator->status());
       iterator->Seek("xa");
       ASSERT_TRUE(iterator->Valid());
       ASSERT_EQ("xb", iterator->key().ToString());
@@ -5799,6 +5866,7 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
 
     {
       std::unique_ptr<Iterator> iterator(db_->NewIterator(ro));
+      ASSERT_OK(iterator->status());
 
       // SeekForPrev() never uses prefix bloom if it is changed.
       iterator->SeekForPrev("xg0");
@@ -5813,6 +5881,7 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
     ub = Slice(ub_str);
     {
       std::unique_ptr<Iterator> iterator(db_->NewIterator(ro));
+      ASSERT_OK(iterator->status());
 
       iterator->Seek("x");
       ASSERT_TRUE(iterator->Valid());
@@ -5859,6 +5928,8 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
       if (expect_filter_check) {
         ASSERT_EQ(4, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
       }
+
+      ASSERT_OK(iterator->status());
     }
     {
       std::unique_ptr<Iterator> iterator(db_->NewIterator(ro));
@@ -5876,6 +5947,8 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
       if (expect_filter_check) {
         ASSERT_EQ(6, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
       }
+
+      ASSERT_OK(iterator->status());
     }
 
     ub_str = "xg9";
@@ -5888,6 +5961,7 @@ TEST_F(DBTest2, ChangePrefixExtractor) {
       if (expect_filter_check) {
         ASSERT_EQ(7, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
       }
+      ASSERT_OK(iterator->status());
     }
   }
 }
@@ -5907,29 +5981,29 @@ TEST_F(DBTest2, BlockBasedTablePrefixGetIndexNotFound) {
   Reopen(options);
 
   ASSERT_OK(Put("b1", "ok"));
-  Flush();
+  ASSERT_OK(Flush());
 
   // Flushing several files so that the chance that hash bucket
   // is empty fo "b" in at least one of the files is high.
   ASSERT_OK(Put("a1", ""));
   ASSERT_OK(Put("c1", ""));
-  Flush();
+  ASSERT_OK(Flush());
 
   ASSERT_OK(Put("a2", ""));
   ASSERT_OK(Put("c2", ""));
-  Flush();
+  ASSERT_OK(Flush());
 
   ASSERT_OK(Put("a3", ""));
   ASSERT_OK(Put("c3", ""));
-  Flush();
+  ASSERT_OK(Flush());
 
   ASSERT_OK(Put("a4", ""));
   ASSERT_OK(Put("c4", ""));
-  Flush();
+  ASSERT_OK(Flush());
 
   ASSERT_OK(Put("a5", ""));
   ASSERT_OK(Put("c5", ""));
-  Flush();
+  ASSERT_OK(Flush());
 
   ASSERT_EQ("ok", Get("b1"));
 }
@@ -5952,7 +6026,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
   ASSERT_OK(Put("a1", large_value));
   ASSERT_OK(Put("x1", large_value));
   ASSERT_OK(Put("y1", large_value));
-  Flush();
+  ASSERT_OK(Flush());
 
   ReadOptions ro;
   ro.total_order_seek = false;
@@ -5963,6 +6037,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
     ASSERT_TRUE(iterator->Valid());
     ASSERT_EQ("x1", iterator->key().ToString());
     ASSERT_EQ(0, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
+    ASSERT_OK(iterator->status());
   }
 
   std::string ub_str = "b9";
@@ -5974,6 +6049,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
     iterator->Seek("b1");
     ASSERT_FALSE(iterator->Valid());
     ASSERT_EQ(1, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
+    ASSERT_OK(iterator->status());
   }
 
   ub_str = "z";
@@ -5984,6 +6060,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
     ASSERT_TRUE(iterator->Valid());
     ASSERT_EQ("x1", iterator->key().ToString());
     ASSERT_EQ(1, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
+    ASSERT_OK(iterator->status());
   }
 
   ub_str = "c";
@@ -5993,6 +6070,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
     iterator->Seek("b1");
     ASSERT_FALSE(iterator->Valid());
     ASSERT_EQ(2, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
+    ASSERT_OK(iterator->status());
   }
 
   // The same queries without recreating iterator
@@ -6005,6 +6083,7 @@ TEST_F(DBTest2, AutoPrefixMode1) {
     iterator->Seek("b1");
     ASSERT_FALSE(iterator->Valid());
     ASSERT_EQ(3, TestGetTickerCount(options, BLOOM_FILTER_PREFIX_CHECKED));
+    ASSERT_OK(iterator->status());
 
     ub_str = "z";
     ub = Slice(ub_str);
index 689af0788f5a357014f13b89ed30aa2724a61c84..1b280093110759cf6bce27ddf276b82e9aceb071 100644 (file)
@@ -403,7 +403,7 @@ class SpecialEnv : public EnvWrapper {
       Status Sync() override {
         ++env_->sync_counter_;
         if (env_->corrupt_in_sync_) {
-          Append(std::string(33000, ' '));
+          EXPECT_OK(Append(std::string(33000, ' ')));
           return Status::IOError("Ingested Sync Failure");
         }
         if (env_->skip_fsync_) {
index 87bf060d1c2e26a61fb3769d7bd7416318662ddc..2cea21ec3c3eb274d56d1aaefe0e7c87dd3ae603 100644 (file)
@@ -395,7 +395,11 @@ IOStatus SetCurrentFile(FileSystem* fs, const std::string& dbname,
       s = directory_to_fsync->Fsync(IOOptions(), nullptr);
     }
   } else {
-    fs->DeleteFile(tmp, IOOptions(), nullptr);
+    fs->DeleteFile(tmp, IOOptions(), nullptr)
+        .PermitUncheckedError();  // NOTE: PermitUncheckedError is acceptable
+                                  // here as we are already handling an error
+                                  // case, and this is just a best-attempt
+                                  // effort at some cleanup
   }
   return s;
 }
index e06d964b52d0b920dac2a29abb121ebd3c63d767..74807ef518528653ef8d6c151de7899ae29b9256 100644 (file)
@@ -62,7 +62,9 @@ class BlockFetcher {
         cache_options_(cache_options),
         memory_allocator_(memory_allocator),
         memory_allocator_compressed_(memory_allocator_compressed),
-        for_compaction_(for_compaction) {}
+        for_compaction_(for_compaction) {
+    io_status_.PermitUncheckedError();  // TODO(AR) can we improve on this?
+  }
 
   IOStatus ReadBlockContents();
   CompressionType get_compression_type() const { return compression_type_; }