Add db_flush_test to ASSERT_STATUS_CHECKED list (#7476)

Summary:
Added status check enforcement for db_flush_test

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

Test Plan: ASSERT_STATUS_CHECKED=1 make -j48 db_flush_test

Reviewed By: akankshamahajan15

Differential Revision: D24033752

Pulled By: zhichao-cao

fbshipit-source-id: d957934e1666d0043bebdd8a4149e94cdcbbb89b
This commit is contained in:
Zhichao Cao 2020-10-12 15:15:58 -07:00 committed by Facebook GitHub Bot
parent 9e03e4dd52
commit 861e544335
4 changed files with 18 additions and 10 deletions

View File

@ -588,6 +588,7 @@ ifdef ASSERT_STATUS_CHECKED
crc32c_test \ crc32c_test \
dbformat_test \ dbformat_test \
db_basic_test \ db_basic_test \
db_flush_test \
db_with_timestamp_basic_test \ db_with_timestamp_basic_test \
db_with_timestamp_compaction_test \ db_with_timestamp_compaction_test \
db_options_test \ db_options_test \

View File

@ -63,7 +63,7 @@ TEST_F(DBFlushTest, FlushWhileWritingManifest) {
ASSERT_OK(Put("bar", "v")); ASSERT_OK(Put("bar", "v"));
ASSERT_OK(dbfull()->Flush(no_wait)); ASSERT_OK(dbfull()->Flush(no_wait));
// If the issue is hit we will wait here forever. // If the issue is hit we will wait here forever.
dbfull()->TEST_WaitForFlushMemTable(); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
ASSERT_EQ(2, TotalTableFiles()); ASSERT_EQ(2, TotalTableFiles());
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
@ -88,7 +88,7 @@ TEST_F(DBFlushTest, SyncFail) {
SyncPoint::GetInstance()->EnableProcessing(); SyncPoint::GetInstance()->EnableProcessing();
CreateAndReopenWithCF({"pikachu"}, options); CreateAndReopenWithCF({"pikachu"}, options);
Put("key", "value"); ASSERT_OK(Put("key", "value"));
auto* cfd = auto* cfd =
static_cast_with_check<ColumnFamilyHandleImpl>(db_->DefaultColumnFamily()) static_cast_with_check<ColumnFamilyHandleImpl>(db_->DefaultColumnFamily())
->cfd(); ->cfd();
@ -107,7 +107,8 @@ TEST_F(DBFlushTest, SyncFail) {
TEST_SYNC_POINT("DBFlushTest::SyncFail:2"); TEST_SYNC_POINT("DBFlushTest::SyncFail:2");
fault_injection_env->SetFilesystemActive(true); fault_injection_env->SetFilesystemActive(true);
// Now the background job will do the flush; wait for it. // Now the background job will do the flush; wait for it.
dbfull()->TEST_WaitForFlushMemTable(); // Returns the IO error happend during flush.
ASSERT_NOK(dbfull()->TEST_WaitForFlushMemTable());
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
ASSERT_EQ("", FilesPerLevel()); // flush failed. ASSERT_EQ("", FilesPerLevel()); // flush failed.
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
@ -126,7 +127,7 @@ TEST_F(DBFlushTest, SyncSkip) {
SyncPoint::GetInstance()->EnableProcessing(); SyncPoint::GetInstance()->EnableProcessing();
Reopen(options); Reopen(options);
Put("key", "value"); ASSERT_OK(Put("key", "value"));
FlushOptions flush_options; FlushOptions flush_options;
flush_options.wait = false; flush_options.wait = false;
@ -136,7 +137,7 @@ TEST_F(DBFlushTest, SyncSkip) {
TEST_SYNC_POINT("DBFlushTest::SyncSkip:2"); TEST_SYNC_POINT("DBFlushTest::SyncSkip:2");
// Now the background job will do the flush; wait for it. // Now the background job will do the flush; wait for it.
dbfull()->TEST_WaitForFlushMemTable(); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
Destroy(options); Destroy(options);
} }
@ -171,9 +172,9 @@ TEST_F(DBFlushTest, FlushInLowPriThreadPool) {
ASSERT_OK(Put("key", "val")); ASSERT_OK(Put("key", "val"));
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
ASSERT_OK(Put("key", "val")); ASSERT_OK(Put("key", "val"));
dbfull()->TEST_WaitForFlushMemTable(); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
} }
dbfull()->TEST_WaitForCompact(); ASSERT_OK(dbfull()->TEST_WaitForCompact());
ASSERT_EQ(4, num_flushes); ASSERT_EQ(4, num_flushes);
ASSERT_EQ(1, num_compactions); ASSERT_EQ(1, num_compactions);
} }
@ -306,7 +307,8 @@ TEST_F(DBFlushTest, ManualFlushFailsInReadOnlyMode) {
// mode. // mode.
fault_injection_env->SetFilesystemActive(false); fault_injection_env->SetFilesystemActive(false);
ASSERT_OK(db_->ContinueBackgroundWork()); ASSERT_OK(db_->ContinueBackgroundWork());
dbfull()->TEST_WaitForFlushMemTable(); // We ingested the error to env, so the returned status is not OK.
ASSERT_NOK(dbfull()->TEST_WaitForFlushMemTable());
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
uint64_t num_bg_errors; uint64_t num_bg_errors;
ASSERT_TRUE(db_->GetIntProperty(DB::Properties::kBackgroundErrors, ASSERT_TRUE(db_->GetIntProperty(DB::Properties::kBackgroundErrors,
@ -713,7 +715,8 @@ TEST_P(DBAtomicFlushTest, AtomicFlushRollbackSomeJobs) {
fault_injection_env->SetFilesystemActive(false); fault_injection_env->SetFilesystemActive(false);
TEST_SYNC_POINT("DBAtomicFlushTest::AtomicFlushRollbackSomeJobs:2"); TEST_SYNC_POINT("DBAtomicFlushTest::AtomicFlushRollbackSomeJobs:2");
for (auto* cfh : handles_) { for (auto* cfh : handles_) {
dbfull()->TEST_WaitForFlushMemTable(cfh); // Returns the IO error happend during flush.
ASSERT_NOK(dbfull()->TEST_WaitForFlushMemTable(cfh));
} }
for (size_t i = 0; i != num_cfs; ++i) { for (size_t i = 0; i != num_cfs; ++i) {
auto cfh = static_cast<ColumnFamilyHandleImpl*>(handles_[i]); auto cfh = static_cast<ColumnFamilyHandleImpl*>(handles_[i]);

View File

@ -459,7 +459,9 @@ void DBImpl::CancelAllBackgroundWork(bool wait) {
autovector<ColumnFamilyData*> cfds; autovector<ColumnFamilyData*> cfds;
SelectColumnFamiliesForAtomicFlush(&cfds); SelectColumnFamiliesForAtomicFlush(&cfds);
mutex_.Unlock(); mutex_.Unlock();
AtomicFlushMemTables(cfds, FlushOptions(), FlushReason::kShutDown); Status s =
AtomicFlushMemTables(cfds, FlushOptions(), FlushReason::kShutDown);
s.PermitUncheckedError(); //**TODO: What to do on error?
mutex_.Lock(); mutex_.Lock();
} else { } else {
for (auto cfd : *versions_->GetColumnFamilySet()) { for (auto cfd : *versions_->GetColumnFamilySet()) {

View File

@ -1784,9 +1784,11 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
// the current log, so treat it as a fatal error and set bg_error // the current log, so treat it as a fatal error and set bg_error
// Should handle return error? // Should handle return error?
if (!io_s.ok()) { if (!io_s.ok()) {
// Should handle return error?
error_handler_.SetBGError(io_s, BackgroundErrorReason::kMemTable) error_handler_.SetBGError(io_s, BackgroundErrorReason::kMemTable)
.PermitUncheckedError(); .PermitUncheckedError();
} else { } else {
// Should handle return error?
error_handler_.SetBGError(s, BackgroundErrorReason::kMemTable) error_handler_.SetBGError(s, BackgroundErrorReason::kMemTable)
.PermitUncheckedError(); .PermitUncheckedError();
} }