diff --git a/repair/row_level.cc b/repair/row_level.cc index da402f8882..45a6f67336 100644 --- a/repair/row_level.cc +++ b/repair/row_level.cc @@ -1385,13 +1385,17 @@ public: public: // Must run inside a seastar thread - void flush_rows_in_working_row_buf(locator::effective_replication_map_ptr erm, bool small_table_optimization) { + void flush_rows_in_working_row_buf(std::optional small_table_optimization) { if (_dirty_on_master) { _dirty_on_master = is_dirty_on_master::no; } else { return; } - flush_rows(_schema, _working_row_buf, _repair_writer, erm, small_table_optimization, this); + if (small_table_optimization) { + flush_rows(_schema, _working_row_buf, _repair_writer, small_table_optimization, this); + } else { + flush_rows(_schema, _working_row_buf, _repair_writer); + } } private: @@ -1933,14 +1937,13 @@ public: } }; -void flush_rows(schema_ptr s, std::list& rows, lw_shared_ptr& writer, locator::effective_replication_map_ptr erm, bool small_table_optimization, repair_meta* rm) { +void flush_rows(schema_ptr s, std::list& rows, lw_shared_ptr& writer, std::optional small_table_optimization, repair_meta* rm) { auto cmp = position_in_partition::tri_compare(*s); lw_shared_ptr last_mf; lw_shared_ptr last_dk; - bool do_small_table_optimization = erm && small_table_optimization; - const auto* tm = do_small_table_optimization ? &erm->get_token_metadata() : nullptr; + const auto* tm = small_table_optimization ? &small_table_optimization->erm->get_token_metadata() : nullptr; - if (do_small_table_optimization && rm) { + if (small_table_optimization && rm) { const auto* tmptr = rm->get_tm_for_small_table_optimization_check(tm).get(); if (tmptr) { tm = tmptr; @@ -1953,10 +1956,10 @@ void flush_rows(schema_ptr s, std::list& rows, lw_shared_ptrdk; - if (do_small_table_optimization) { + if (small_table_optimization) { // Check if the token is owned by the node - auto eps = erm->get_replication_strategy().calculate_natural_endpoints(dk.token(), *tm).get(); - if (!eps.contains(erm->get_topology().my_host_id())) { + auto eps = small_table_optimization->erm->get_replication_strategy().calculate_natural_endpoints(dk.token(), *tm).get(); + if (!eps.contains(small_table_optimization->erm->get_topology().my_host_id())) { rlogger.trace("master: ignore row, token={}", dk.token()); continue; } @@ -2937,7 +2940,7 @@ private: throw; } } - master.flush_rows_in_working_row_buf(get_erm(), _small_table_optimization); + master.flush_rows_in_working_row_buf(_small_table_optimization ? std::make_optional(small_table_optimization_params{ .erm = get_erm() }) : std::nullopt); return op_status::next_step; } diff --git a/repair/row_level.hh b/repair/row_level.hh index 34ff1bacf1..c14f5d83c4 100644 --- a/repair/row_level.hh +++ b/repair/row_level.hh @@ -42,6 +42,10 @@ namespace gms { class gossiper; } +struct small_table_optimization_params { + locator::effective_replication_map_ptr erm; +}; + class repair_meta; using repair_meta_ptr = shared_ptr; @@ -279,4 +283,4 @@ future<> repair_cf_range_row_level(repair::shard_repair_task_impl& shard_task, future> to_repair_rows_list(repair_rows_on_wire rows, schema_ptr s, uint64_t seed, repair_master is_master, reader_permit permit, repair_hasher hasher); -void flush_rows(schema_ptr s, std::list& rows, lw_shared_ptr& writer, locator::effective_replication_map_ptr erm = {}, bool small_table_optimization = false, repair_meta* rm = nullptr); +void flush_rows(schema_ptr s, std::list& rows, lw_shared_ptr& writer, std::optional small_table_optimization = std::nullopt, repair_meta* rm = nullptr);