Compare commits

...

3 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
b549a9b8f2 Store active transitions count in load_balancer instance
Move _active_transitions from migration_plan to load_balancer class
as a member variable. This is cleaner since there's no concurrent
make_plan() calls on the same load_balancer instance.

Changes:
- Removed _active_transitions field from migration_plan
- Added _active_transitions member to load_balancer class
- Updated make_plan() to reset counter at the start
- Log messages now reference _active_transitions directly

Co-authored-by: tgrabiec <283695+tgrabiec@users.noreply.github.com>
2026-01-08 13:38:27 +00:00
copilot-swe-agent[bot]
965bc9e5d0 Add active tablet transition count to load balancer logs
Track and report the number of active tablet transitions when
making migration plans. This helps operators understand the
current streaming load when the load balancer is preparing
new migrations.

Co-authored-by: tgrabiec <283695+tgrabiec@users.noreply.github.com>
2026-01-07 18:51:18 +00:00
copilot-swe-agent[bot]
179c8ac67f Initial plan 2026-01-07 18:12:46 +00:00

View File

@@ -832,6 +832,8 @@ class load_balancer {
std::unordered_set<host_id> _skiplist;
bool _use_table_aware_balancing = true;
double _initial_scale = 1;
// Number of active tablet transitions counted during plan creation.
size_t _active_transitions = 0;
// This is the maximum load delta between the most and least loaded nodes,
// below which the balancer considers the DC balanced
@@ -950,6 +952,8 @@ public:
const locator::topology& topo = _tm->get_topology();
migration_plan plan;
_active_transitions = 0; // Reset for this make_plan() call
auto rack_list_colocation = ongoing_rack_list_colocation();
if (!utils::get_local_injector().enter("tablet_migration_bypass")) {
// Prepare plans for each DC separately and combine them to be executed in parallel.
@@ -958,13 +962,15 @@ public:
for (auto rack : topo.get_datacenter_racks().at(dc) | std::views::keys) {
auto rack_plan = co_await make_plan(dc, rack);
auto level = rack_plan.size() > 0 ? seastar::log_level::info : seastar::log_level::debug;
lblogger.log(level, "Prepared {} migrations in rack {} in DC {}", rack_plan.size(), rack, dc);
lblogger.log(level, "Prepared {} migrations in rack {} in DC {} (active transitions: {})",
rack_plan.size(), rack, dc, _active_transitions);
plan.merge(std::move(rack_plan));
}
} else {
auto dc_plan = co_await make_plan(dc);
auto level = dc_plan.size() > 0 ? seastar::log_level::info : seastar::log_level::debug;
lblogger.log(level, "Prepared {} migrations in DC {}", dc_plan.size(), dc);
lblogger.log(level, "Prepared {} migrations in DC {} (active transitions: {})",
dc_plan.size(), dc, _active_transitions);
plan.merge(std::move(dc_plan));
}
}
@@ -3519,6 +3525,7 @@ public:
auto maybe_apply_load = [&] (std::optional<tablet_desc> t) {
if (t && is_streaming(t->transition)) {
apply_load(nodes, get_migration_streaming_info(topo, *t->info, *t->transition));
_active_transitions++;
}
};
@@ -3666,7 +3673,8 @@ public:
if (_tm->tablets().balancing_enabled() && plan.empty() && !ongoing_rack_list_colocation()) {
auto dc_merge_plan = co_await make_merge_colocation_plan(dc, nodes);
auto level = dc_merge_plan.tablet_migration_count() > 0 ? seastar::log_level::info : seastar::log_level::debug;
lblogger.log(level, "Prepared {} migrations for co-locating sibling tablets in DC {}", dc_merge_plan.tablet_migration_count(), dc);
lblogger.log(level, "Prepared {} migrations for co-locating sibling tablets in DC {} (active transitions: {})",
dc_merge_plan.tablet_migration_count(), dc, _active_transitions);
plan.merge(std::move(dc_merge_plan));
}