Skip to content

Commit 15a7e9e

Browse files
committed
Add test_follower flag to crash test
1 parent 44b741e commit 15a7e9e

File tree

7 files changed

+36
-5
lines changed

7 files changed

+36
-5
lines changed

db_stress_tool/db_stress_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ DECLARE_int32(index_type);
176176
DECLARE_int32(data_block_index_type);
177177
DECLARE_string(db);
178178
DECLARE_string(secondaries_base);
179+
DECLARE_string(followers_base);
179180
DECLARE_bool(test_secondary);
181+
DECLARE_bool(test_follower);
180182
DECLARE_string(expected_values_dir);
181183
DECLARE_bool(verify_checksum);
182184
DECLARE_bool(mmap_read);

db_stress_tool/db_stress_gflags.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,17 @@ DEFINE_string(db, "", "Use the db with the following name.");
618618
DEFINE_string(secondaries_base, "",
619619
"Use this path as the base path for secondary instances.");
620620

621+
DEFINE_string(followers_base, "",
622+
"Use this path as the base path for follower instances.");
623+
621624
DEFINE_bool(test_secondary, false,
622625
"If true, start an additional secondary instance which can be used "
623626
"for verification.");
624627

628+
DEFINE_bool(test_follower, false,
629+
"If true, start an additional follower instance which can be used "
630+
"for verification.");
631+
625632
DEFINE_string(
626633
expected_values_dir, "",
627634
"Dir where files containing info about the latest/historical values will "

db_stress_tool/db_stress_stat.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace ROCKSDB_NAMESPACE {
1111

1212
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats;
1313
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_secondaries;
14+
std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_followers;
1415

1516
} // namespace ROCKSDB_NAMESPACE
1617

db_stress_tool/db_stress_stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace ROCKSDB_NAMESPACE {
2525
// Database statistics
2626
extern std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats;
2727
extern std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_secondaries;
28+
extern std::shared_ptr<ROCKSDB_NAMESPACE::Statistics> dbstats_followers;
2829

2930
class Stats {
3031
private:

db_stress_tool/db_stress_test_base.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,10 @@ void StressTest::PrintStatistics() {
645645
fprintf(stdout, "Secondary instances STATISTICS:\n%s\n",
646646
dbstats_secondaries->ToString().c_str());
647647
}
648+
if (dbstats_followers) {
649+
fprintf(stdout, "Follower instances STATISTICS:\n%s\n",
650+
dbstats_followers->ToString().c_str());
651+
}
648652
}
649653

650654
// Currently PreloadDb has to be single-threaded.

db_stress_tool/db_stress_tool.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ int db_stress_tool(int argc, char** argv) {
5858
if (FLAGS_test_secondary) {
5959
dbstats_secondaries = ROCKSDB_NAMESPACE::CreateDBStatistics();
6060
}
61+
if (FLAGS_test_follower) {
62+
dbstats_followers = ROCKSDB_NAMESPACE::CreateDBStatistics();
63+
}
6164
}
6265
compression_type_e = StringToCompressionType(FLAGS_compression_type.c_str());
6366
bottommost_compression_type_e =
@@ -231,6 +234,19 @@ int db_stress_tool(int argc, char** argv) {
231234
FLAGS_secondaries_base = default_secondaries_path;
232235
}
233236

237+
if (FLAGS_test_follower && FLAGS_followers_base.empty()) {
238+
std::string default_followers_path;
239+
db_stress_env->GetTestDirectory(&default_followers_path);
240+
default_followers_path += "/dbstress_followers";
241+
s = db_stress_env->CreateDirIfMissing(default_followers_path);
242+
if (!s.ok()) {
243+
fprintf(stderr, "Failed to create directory %s: %s\n",
244+
default_followers_path.c_str(), s.ToString().c_str());
245+
exit(1);
246+
}
247+
FLAGS_followers_base = default_followers_path;
248+
}
249+
234250
if (FLAGS_best_efforts_recovery &&
235251
!(FLAGS_skip_verifydb && FLAGS_disable_wal)) {
236252
fprintf(stderr,

db_stress_tool/multi_ops_txns_stress.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,11 +1759,11 @@ void CheckAndSetOptionsForMultiOpsTxnStressTest() {
17591759
if (!FLAGS_use_txn) {
17601760
fprintf(stderr, "-use_txn must be true if -test_multi_ops_txns\n");
17611761
exit(1);
1762-
} else if (FLAGS_test_secondary > 0) {
1763-
fprintf(
1764-
stderr,
1765-
"secondary instance does not support replaying logs (MANIFEST + WAL) "
1766-
"of TransactionDB with write-prepared/write-unprepared policy\n");
1762+
} else if (FLAGS_test_secondary > 0 || FLAGS_test_follower > 0) {
1763+
fprintf(stderr,
1764+
"secondary and follower instances do not support replaying logs "
1765+
"(MANIFEST + WAL) "
1766+
"of TransactionDB with write-prepared/write-unprepared policy\n");
17671767
exit(1);
17681768
}
17691769
if (FLAGS_clear_column_family_one_in > 0) {

0 commit comments

Comments
 (0)