Skip to content

Commit eedb997

Browse files
committed
Merge 'compaction: upgrade: handle keyspaces that use tablets' from Lakshmi Narayanan Sreethar
Tables in keyspaces governed by replication strategy that uses tablets, have separate effective_replication_maps. Update the upgrade compaction task to handle this when getting owned key ranges for a keyspace. Fixes scylladb#16848 Closes scylladb#17335 * github.com:scylladb/scylladb: compaction: upgrade: handle keyspaces that use tablets replica/database: add an optional variant to get_keyspace_local_ranges
2 parents f0b3068 + 7a98877 commit eedb997

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compaction/task_manager_module.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ future<> shard_upgrade_sstables_compaction_task_impl::run() {
531531

532532
future<> table_upgrade_sstables_compaction_task_impl::run() {
533533
co_await wait_for_your_turn(_cv, _current_task, _status.id);
534-
auto owned_ranges_ptr = compaction::make_owned_ranges_ptr(_db.get_keyspace_local_ranges(_status.keyspace));
534+
auto owned_ranges = _db.maybe_get_keyspace_local_ranges(_status.keyspace);
535+
auto owned_ranges_ptr = owned_ranges ? compaction::make_owned_ranges_ptr(std::move(owned_ranges.value())) : nullptr;
535536
tasks::task_info info{_status.id, _status.shard};
536537
co_await run_on_table("upgrade_sstables", _db, _status.keyspace, _ti, [&] (replica::table& t) -> future<> {
537538
return t.parallel_foreach_table_state([&] (compaction::table_state& ts) -> future<> {

replica/database.cc

+10
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,16 @@ dht::token_range_vector database::get_keyspace_local_ranges(sstring ks) {
25912591
return find_keyspace(ks).get_vnode_effective_replication_map()->get_ranges(my_address);
25922592
}
25932593

2594+
std::optional<dht::token_range_vector> database::maybe_get_keyspace_local_ranges(sstring ks) {
2595+
const auto& keyspace = find_keyspace(ks);
2596+
if (keyspace.get_replication_strategy().is_per_table()) {
2597+
// return nullopt if each tables have their own effective_replication_map
2598+
return std::nullopt;
2599+
}
2600+
auto my_address = get_token_metadata().get_topology().my_address();
2601+
return keyspace.get_vnode_effective_replication_map()->get_ranges(my_address);
2602+
}
2603+
25942604
/*!
25952605
* \brief a helper function that gets a table name and returns a prefix
25962606
* of the directory name of the table.

replica/database.hh

+1
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ public:
18001800
// Returns the list of ranges held by this endpoint
18011801
// The returned list is sorted, and its elements are non overlapping and non wrap-around.
18021802
dht::token_range_vector get_keyspace_local_ranges(sstring ks);
1803+
std::optional<dht::token_range_vector> maybe_get_keyspace_local_ranges(sstring ks);
18031804

18041805
void set_format(sstables::sstable_version_types format) noexcept;
18051806
void set_format_by_config();

0 commit comments

Comments
 (0)