db_stress: Added the verification for GetLiveFiles, GetSortedWalFiles and GetCurrentWalFile (#6224)

Summary:
Add the verification in operateDB to verify GetLiveFiles, GetSortedWalFiles and GetCurrentWalFile. The test will be called every 1 out of N, N is decided by get_live_files_and_wal_files_one_i, whose default is 1000000.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6224

Test Plan: pass db_stress default run.

Differential Revision: D19183358

Pulled By: zhichao-cao

fbshipit-source-id: 20073cf72ede77a3e0d3cf5f28304f1f605d2b1a
main
Zhichao Cao 5 years ago committed by Facebook Github Bot
parent c4fd9cf461
commit f89dea4fec
  1. 1
      db_stress_tool/db_stress_common.h
  2. 5
      db_stress_tool/db_stress_gflags.cc
  3. 39
      db_stress_tool/db_stress_test_base.cc
  4. 4
      db_stress_tool/db_stress_test_base.h
  5. 1
      tools/db_crashtest.py

@ -125,6 +125,7 @@ DECLARE_int32(universal_min_merge_width);
DECLARE_int32(universal_max_merge_width); DECLARE_int32(universal_max_merge_width);
DECLARE_int32(universal_max_size_amplification_percent); DECLARE_int32(universal_max_size_amplification_percent);
DECLARE_int32(clear_column_family_one_in); DECLARE_int32(clear_column_family_one_in);
DECLARE_int32(get_live_files_and_wal_files_one_in);
DECLARE_int32(set_options_one_in); DECLARE_int32(set_options_one_in);
DECLARE_int32(set_in_place_one_in); DECLARE_int32(set_in_place_one_in);
DECLARE_int64(cache_size); DECLARE_int64(cache_size);

@ -239,6 +239,11 @@ DEFINE_int32(clear_column_family_one_in, 1000000,
"it again. If N == 0, never drop/create column families. " "it again. If N == 0, never drop/create column families. "
"When test_batches_snapshots is true, this flag has no effect"); "When test_batches_snapshots is true, this flag has no effect");
DEFINE_int32(get_live_files_and_wal_files_one_in, 1000000,
"With a chance of 1/N, call GetLiveFiles, GetSortedWalFiles "
"and GetCurrentWalFile to verify if it returns correctly. If "
"N == 0, never call the three interfaces.");
DEFINE_int32(set_options_one_in, 0, DEFINE_int32(set_options_one_in, 0,
"With a chance of 1/N, change some random options"); "With a chance of 1/N, change some random options");

@ -581,6 +581,19 @@ void StressTest::OperateDb(ThreadState* thread) {
} }
} }
#ifndef ROCKSDB_LITE
// Every 1 in N verify the one of the following: 1) GetLiveFiles
// 2) GetSortedWalFiles 3) GetCurrentWalFile. Each time, randomly select
// one of them to run the test.
if (thread->rand.OneInOpt(FLAGS_get_live_files_and_wal_files_one_in)) {
Status status = VerifyGetLiveAndWalFiles(thread);
if (!status.ok()) {
VerificationAbort(shared, "VerifyGetLiveAndWalFiles status not OK",
status);
}
}
#endif // !ROCKSDB_LITE
if (thread->rand.OneInOpt(FLAGS_pause_background_one_in)) { if (thread->rand.OneInOpt(FLAGS_pause_background_one_in)) {
Status status = TestPauseBackground(thread); Status status = TestPauseBackground(thread);
if (!status.ok()) { if (!status.ok()) {
@ -890,6 +903,32 @@ Status StressTest::TestIterate(ThreadState* thread,
return s; return s;
} }
#ifndef ROCKSDB_LITE
// Test the return status of GetLiveFiles, GetSortedWalFiles, and
// GetCurrentWalFile. Each time, randomly select one of them to run
// and return the status.
Status StressTest::VerifyGetLiveAndWalFiles(ThreadState* thread) {
int case_num = thread->rand.Uniform(3);
if (case_num == 0) {
std::vector<std::string> live_file;
uint64_t manifest_size;
return db_->GetLiveFiles(live_file, &manifest_size);
}
if (case_num == 1) {
VectorLogPtr log_ptr;
return db_->GetSortedWalFiles(log_ptr);
}
if (case_num == 2) {
std::unique_ptr<LogFile> cur_wal_file;
return db_->GetCurrentWalFile(&cur_wal_file);
}
assert(false);
return Status::Corruption("Undefined case happens!");
}
#endif // !ROCKSDB_LITE
// Compare the two iterator, iter and cmp_iter are in the same position, // Compare the two iterator, iter and cmp_iter are in the same position,
// unless iter might be made invalidate or undefined because of // unless iter might be made invalidate or undefined because of
// upper or lower bounds, or prefix extractor. // upper or lower bounds, or prefix extractor.

@ -173,7 +173,9 @@ class StressTest {
const std::string& keystr, uint64_t i); const std::string& keystr, uint64_t i);
Status MaybeReleaseSnapshots(ThreadState* thread, uint64_t i); Status MaybeReleaseSnapshots(ThreadState* thread, uint64_t i);
#ifndef ROCKSDB_LITE
Status VerifyGetLiveAndWalFiles(ThreadState* thread);
#endif // !ROCKSDB_LITE
void VerificationAbort(SharedState* shared, std::string msg, Status s) const; void VerificationAbort(SharedState* shared, std::string msg, Status s) const;
void VerificationAbort(SharedState* shared, std::string msg, int cf, void VerificationAbort(SharedState* shared, std::string msg, int cf,

@ -46,6 +46,7 @@ default_params = {
"enable_pipelined_write": lambda: random.randint(0, 1), "enable_pipelined_write": lambda: random.randint(0, 1),
"expected_values_path": expected_values_file.name, "expected_values_path": expected_values_file.name,
"flush_one_in": 1000000, "flush_one_in": 1000000,
"get_live_files_and_wal_files_one_in": 1000000,
# Temporarily disable hash index # Temporarily disable hash index
"index_type": lambda: random.choice([0,2]), "index_type": lambda: random.choice([0,2]),
"max_background_compactions": 20, "max_background_compactions": 20,

Loading…
Cancel
Save