compaction: Keep database reference on upgrade options
The only place that creates them is the API upgrade_sstables call. The created options object doesn't over-survive the returned future, so it's safe to keep this reference there. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -437,7 +437,7 @@ void set_storage_service(http_context& ctx, routes& r) {
|
||||
return do_for_each(column_families, [=, &db](sstring cfname) {
|
||||
auto& cm = db.get_compaction_manager();
|
||||
auto& cf = db.find_column_family(keyspace, cfname);
|
||||
return cm.perform_sstable_upgrade(&cf, exclude_current_version);
|
||||
return cm.perform_sstable_upgrade(db, &cf, exclude_current_version);
|
||||
});
|
||||
}).then([]{
|
||||
return make_ready_future<json::json_return_type>(0);
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
std::reference_wrapper<database> db;
|
||||
};
|
||||
struct upgrade {
|
||||
std::reference_wrapper<database> db;
|
||||
};
|
||||
struct scrub {
|
||||
bool skip_corrupted;
|
||||
@@ -105,8 +106,8 @@ public:
|
||||
return compaction_options(cleanup{db});
|
||||
}
|
||||
|
||||
static compaction_options make_upgrade() {
|
||||
return compaction_options(upgrade{});
|
||||
static compaction_options make_upgrade(database& db) {
|
||||
return compaction_options(upgrade{db});
|
||||
}
|
||||
|
||||
static compaction_options make_scrub(bool skip_corrupted) {
|
||||
|
||||
@@ -745,9 +745,9 @@ future<> compaction_manager::perform_cleanup(database& db, column_family* cf) {
|
||||
}
|
||||
|
||||
// Submit a column family to be upgraded and wait for its termination.
|
||||
future<> compaction_manager::perform_sstable_upgrade(column_family* cf, bool exclude_current_version) {
|
||||
future<> compaction_manager::perform_sstable_upgrade(database& db, column_family* cf, bool exclude_current_version) {
|
||||
using shared_sstables = std::vector<sstables::shared_sstable>;
|
||||
return do_with(shared_sstables{}, [this, cf, exclude_current_version](shared_sstables& tables) {
|
||||
return do_with(shared_sstables{}, [this, &db, cf, exclude_current_version](shared_sstables& tables) {
|
||||
// since we might potentially have ongoing compactions, and we
|
||||
// must ensure that all sstables created before we run are included
|
||||
// in the re-write, we need to barrier out any previously running
|
||||
@@ -764,14 +764,14 @@ future<> compaction_manager::perform_sstable_upgrade(column_family* cf, bool exc
|
||||
}
|
||||
}
|
||||
return make_ready_future<>();
|
||||
}).then([this, cf, &tables] {
|
||||
}).then([this, &db, cf, &tables] {
|
||||
// doing a "cleanup" is about as compacting as we need
|
||||
// to be, provided we get to decide the tables to process,
|
||||
// and ignoring any existing operations.
|
||||
// Note that we potentially could be doing multiple
|
||||
// upgrades here in parallel, but that is really the users
|
||||
// problem.
|
||||
return rewrite_sstables(cf, sstables::compaction_options::make_upgrade(), [&](auto&) mutable {
|
||||
return rewrite_sstables(cf, sstables::compaction_options::make_upgrade(db), [&](auto&) mutable {
|
||||
return std::exchange(tables, {});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
future<> perform_cleanup(database& db, column_family* cf);
|
||||
|
||||
// Submit a column family to be upgraded and wait for its termination.
|
||||
future<> perform_sstable_upgrade(column_family* cf, bool exclude_current_version);
|
||||
future<> perform_sstable_upgrade(database& db, column_family* cf, bool exclude_current_version);
|
||||
|
||||
// Submit a column family to be scrubbed and wait for its termination.
|
||||
future<> perform_sstable_scrub(column_family* cf, bool skip_corrupted);
|
||||
|
||||
Reference in New Issue
Block a user