Use FaultInjectionTestFS in DBWriteTest.LockWALInEffect (#11271)

Summary:
Existing use of FaultInjectionTestEnv shows rare TSAN errors with parallel Sync and Flush. This appears to be fixed in FaultInjectionTestFS. (Sigh, code duplication and divergence.)

Example failure:
https://app.circleci.com/pipelines/github/facebook/rocksdb/24631/workflows/fc2a66f0-f21c-48d6-a944-3885bcff50a4/jobs/571928

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

Test Plan: wasn't able to reproduce locally but stress tested the updated test with gtest-parallel -r1000 and TSAN.

Reviewed By: ajkr

Differential Revision: D43779477

Pulled By: pdillinger

fbshipit-source-id: a019b0f1d4045a26a15ab08aab63828a398f6d3e
oxigraph-8.1.1
Peter Dillinger 2 years ago committed by Facebook GitHub Bot
parent ddde1e6af8
commit e168c1b1a4
  1. 16
      db/db_write_test.cc

@ -19,6 +19,7 @@
#include "util/random.h" #include "util/random.h"
#include "util/string_util.h" #include "util/string_util.h"
#include "utilities/fault_injection_env.h" #include "utilities/fault_injection_env.h"
#include "utilities/fault_injection_fs.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
@ -608,10 +609,15 @@ TEST_P(DBWriteTest, IOErrorOnSwitchMemtable) {
// Test that db->LockWAL() flushes the WAL after locking, which can fail // Test that db->LockWAL() flushes the WAL after locking, which can fail
TEST_P(DBWriteTest, LockWALInEffect) { TEST_P(DBWriteTest, LockWALInEffect) {
if (mem_env_ || encrypted_env_) {
ROCKSDB_GTEST_SKIP("Test requires non-mem or non-encrypted environment");
return;
}
Options options = GetOptions(); Options options = GetOptions();
std::unique_ptr<FaultInjectionTestEnv> mock_env( std::shared_ptr<FaultInjectionTestFS> fault_fs(
new FaultInjectionTestEnv(env_)); new FaultInjectionTestFS(FileSystem::Default()));
options.env = mock_env.get(); std::unique_ptr<Env> fault_fs_env(NewCompositeEnv(fault_fs));
options.env = fault_fs_env.get();
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
options.paranoid_checks = false; options.paranoid_checks = false;
Reopen(options); Reopen(options);
@ -630,7 +636,7 @@ TEST_P(DBWriteTest, LockWALInEffect) {
ASSERT_OK(db_->UnlockWAL()); ASSERT_OK(db_->UnlockWAL());
// Fail the WAL flush if applicable // Fail the WAL flush if applicable
mock_env->SetFilesystemActive(false); fault_fs->SetFilesystemActive(false);
Status s = Put("key2", "value"); Status s = Put("key2", "value");
if (options.manual_wal_flush) { if (options.manual_wal_flush) {
ASSERT_OK(s); ASSERT_OK(s);
@ -642,7 +648,7 @@ TEST_P(DBWriteTest, LockWALInEffect) {
ASSERT_OK(db_->LockWAL()); ASSERT_OK(db_->LockWAL());
ASSERT_OK(db_->UnlockWAL()); ASSERT_OK(db_->UnlockWAL());
} }
mock_env->SetFilesystemActive(true); fault_fs->SetFilesystemActive(true);
// Writes should work again // Writes should work again
ASSERT_OK(Put("key3", "value")); ASSERT_OK(Put("key3", "value"));
ASSERT_EQ(Get("key3"), "value"); ASSERT_EQ(Get("key3"), "value");

Loading…
Cancel
Save