Skip to content

Commit

Permalink
Add enable_remote_compaction option to DB Stress (#13378)
Browse files Browse the repository at this point in the history
Summary:
First step to add (simulated) Remote Compaction in Stress Test. More PRs to come. Just first PR to add the FLAG to enable it. `DbStressCompactionService` will return `kUseLocal` for all compactions.

Pull Request resolved: #13378

Test Plan:
```
python3 -u tools/db_crashtest.py whitebox --enable_remote_compaction=1
```
```
python3 -u tools/db_crashtest.py blackbox --enable_remote_compaction=1
```

Reviewed By: hx235

Differential Revision: D69269568

Pulled By: jaykorean

fbshipit-source-id: 5119bb6afd4d52f66923fb095150d3132226f7ba
  • Loading branch information
jaykorean authored and facebook-github-bot committed Feb 7, 2025
1 parent 62531da commit 302254d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions db_stress_tool/db_stress_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ DECLARE_bool(allow_unprepared_value);
DECLARE_string(file_temperature_age_thresholds);
DECLARE_uint32(commit_bypass_memtable_one_in);
DECLARE_bool(track_and_verify_wals);
DECLARE_bool(enable_remote_compaction);

constexpr long KB = 1024;
constexpr int kRandomValueMaxFactor = 3;
Expand Down
39 changes: 39 additions & 0 deletions db_stress_tool/db_stress_compaction_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).

#pragma once

#include "rocksdb/options.h"

namespace ROCKSDB_NAMESPACE {

// Service to simulate Remote Compaction in Stress Test
class DbStressCompactionService : public CompactionService {
public:
explicit DbStressCompactionService() {}

static const char* kClassName() { return "DbStressCompactionService"; }

const char* Name() const override { return kClassName(); }

CompactionServiceScheduleResponse Schedule(
const CompactionServiceJobInfo& /*info*/,
const std::string& /*compaction_service_input*/) override {
CompactionServiceScheduleResponse response(
"Implement Me", CompactionServiceJobStatus::kUseLocal);
return response;
}

CompactionServiceJobStatus Wait(const std::string& /*scheduled_job_id*/,
std::string* /*result*/) override {
// TODO - Implement
return CompactionServiceJobStatus::kUseLocal;
}

// TODO - Implement
void CancelAwaitingJobs() override {}
};

} // namespace ROCKSDB_NAMESPACE
3 changes: 3 additions & 0 deletions db_stress_tool/db_stress_gflags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,9 @@ DEFINE_bool(track_and_verify_wals,
ROCKSDB_NAMESPACE::Options().track_and_verify_wals,
"See Options::track_and_verify_wals");

DEFINE_bool(enable_remote_compaction, false,
"Enable (simulated) Remote Compaction");

static bool ValidateInt32Percent(const char* flagname, int32_t value) {
if (value < 0 || value > 100) {
fprintf(stderr, "Invalid value for --%s: %d, 0<= pct <=100 \n", flagname,
Expand Down
6 changes: 6 additions & 0 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifdef GFLAGS
#include "db_stress_tool/db_stress_common.h"
#include "db_stress_tool/db_stress_compaction_filter.h"
#include "db_stress_tool/db_stress_compaction_service.h"
#include "db_stress_tool/db_stress_driver.h"
#include "db_stress_tool/db_stress_filters.h"
#include "db_stress_tool/db_stress_table_properties_collector.h"
Expand Down Expand Up @@ -4297,6 +4298,11 @@ void InitializeOptionsFromFlags(
static_cast<CacheTier>(FLAGS_lowest_used_cache_tier);
options.inplace_update_support = FLAGS_inplace_update_support;
options.uncache_aggressiveness = FLAGS_uncache_aggressiveness;

// Remote Compaction
if (FLAGS_enable_remote_compaction) {
options.compaction_service = std::make_shared<DbStressCompactionService>();
}
}

void InitializeOptionsGeneral(
Expand Down
1 change: 1 addition & 0 deletions tools/db_crashtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
"paranoid_memory_checks": lambda: random.choice([0] * 7 + [1]),
"allow_unprepared_value": lambda: random.choice([0, 1]),
"track_and_verify_wals": lambda: random.choice([0, 1]),
"enable_remote_compaction": lambda: random.choice([0, 1]),
}
_TEST_DIR_ENV_VAR = "TEST_TMPDIR"
# If TEST_TMPDIR_EXPECTED is not specified, default value will be TEST_TMPDIR
Expand Down

0 comments on commit 302254d

Please sign in to comment.