Skip to content

Commit

Permalink
Add test_follower flag to crash test
Browse files Browse the repository at this point in the history
  • Loading branch information
archang19 committed Jan 9, 2025
1 parent d4bd67f commit 2ca0fcd
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions db_stress_tool/db_stress_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ DECLARE_int32(index_type);
DECLARE_int32(data_block_index_type);
DECLARE_string(db);
DECLARE_string(secondaries_base);
DECLARE_string(followers_base);
DECLARE_bool(test_secondary);
DECLARE_bool(test_follower);
DECLARE_string(expected_values_dir);
DECLARE_bool(verify_checksum);
DECLARE_bool(mmap_read);
Expand Down
7 changes: 7 additions & 0 deletions db_stress_tool/db_stress_gflags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,17 @@ DEFINE_string(db, "", "Use the db with the following name.");
DEFINE_string(secondaries_base, "",
"Use this path as the base path for secondary instances.");

DEFINE_string(followers_base, "",
"Use this path as the base path for follower instances.");

DEFINE_bool(test_secondary, false,
"If true, start an additional secondary instance which can be used "
"for verification.");

DEFINE_bool(test_follower, false,
"If true, start an additional follower instance which can be used "
"for verification.");

DEFINE_string(
expected_values_dir, "",
"Dir where files containing info about the latest/historical values will "
Expand Down
1 change: 1 addition & 0 deletions db_stress_tool/db_stress_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ROCKSDB_NAMESPACE {

std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats;
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_secondaries;
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_followers;

} // namespace ROCKSDB_NAMESPACE

Expand Down
1 change: 1 addition & 0 deletions db_stress_tool/db_stress_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace ROCKSDB_NAMESPACE {
// Database statistics
extern std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats;
extern std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_secondaries;
extern std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_followers;

class Stats {
private:
Expand Down
4 changes: 4 additions & 0 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@ void StressTest::PrintStatistics() {
fprintf(stdout, "Secondary instances STATISTICS:\n%s\n",
dbstats_secondaries->ToString().c_str());
}
if (dbstats_followers) {
fprintf(stdout, "Follower instances STATISTICS:\n%s\n",
dbstats_followers->ToString().c_str());
}
}

// Currently PreloadDb has to be single-threaded.
Expand Down
16 changes: 16 additions & 0 deletions db_stress_tool/db_stress_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ int db_stress_tool(int argc, char** argv) {
if (FLAGS_test_secondary) {
dbstats_secondaries = ROCKSDB_NAMESPACE::CreateDBStatistics();
}
if (FLAGS_test_follower) {
dbstats_followers = ROCKSDB_NAMESPACE::CreateDBStatistics();
}
}
compression_type_e = StringToCompressionType(FLAGS_compression_type.c_str());
bottommost_compression_type_e =
Expand Down Expand Up @@ -231,6 +234,19 @@ int db_stress_tool(int argc, char** argv) {
FLAGS_secondaries_base = default_secondaries_path;
}

if (FLAGS_test_follower && FLAGS_followers_base.empty()) {
std::string default_followers_path;
db_stress_env->GetTestDirectory(&default_followers_path);
default_followers_path += "/dbstress_followers";
s = db_stress_env->CreateDirIfMissing(default_followers_path);
if (!s.ok()) {
fprintf(stderr, "Failed to create directory %s: %s\n",
default_followers_path.c_str(), s.ToString().c_str());
exit(1);
}
FLAGS_followers_base = default_followers_path;
}

if (FLAGS_best_efforts_recovery &&
!(FLAGS_skip_verifydb && FLAGS_disable_wal)) {
fprintf(stderr,
Expand Down
10 changes: 5 additions & 5 deletions db_stress_tool/multi_ops_txns_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1759,11 +1759,11 @@ void CheckAndSetOptionsForMultiOpsTxnStressTest() {
if (!FLAGS_use_txn) {
fprintf(stderr, "-use_txn must be true if -test_multi_ops_txns\n");
exit(1);
} else if (FLAGS_test_secondary > 0) {
fprintf(
stderr,
"secondary instance does not support replaying logs (MANIFEST + WAL) "
"of TransactionDB with write-prepared/write-unprepared policy\n");
} else if (FLAGS_test_secondary > 0 || FLAGS_test_follower > 0) {
fprintf(stderr,
"secondary and follower instances do not support replaying logs "
"(MANIFEST + WAL) "
"of TransactionDB with write-prepared/write-unprepared policy\n");
exit(1);
}
if (FLAGS_clear_column_family_one_in > 0) {
Expand Down

0 comments on commit 2ca0fcd

Please sign in to comment.