Skip to content

Commit

Permalink
c/partition_balancer: add disk size trace logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ztlpn committed Sep 26, 2023
1 parent 794d280 commit 01493a3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
48 changes: 46 additions & 2 deletions src/v/cluster/partition_balancer_planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,18 @@ ss::future<> partition_balancer_planner::init_ntp_sizes_from_health_report(
for (const auto& tp_ns : node_report.topics) {
for (const auto& partition : tp_ns.partitions) {
model::ntp ntp{tp_ns.tp_ns.ns, tp_ns.tp_ns.tp, partition.id};
size_t reclaimable = partition.reclaimable_size_bytes.value_or(
0);
vlog(
clusterlog.trace,
"ntp {} on node {}: size {}, reclaimable: {}",
ntp,
human::bytes(partition.size_bytes),
human::bytes(reclaimable));

auto& sizes = ctx._ntp2sizes[ntp];
sizes.current[node_report.id] = partition.size_bytes;

size_t reclaimable = partition.reclaimable_size_bytes.value_or(
0);
size_t non_reclaimable = 0;
if (reclaimable < partition.size_bytes) {
non_reclaimable = partition.size_bytes - reclaimable;
Expand Down Expand Up @@ -398,6 +405,14 @@ ss::future<> partition_balancer_planner::init_ntp_sizes_from_health_report(
break;
}
}

for (const auto& [id, disk] : ctx.node_disk_reports) {
vlog(
clusterlog.trace,
"after processing in-progress updates, node id {} disk: {}",
id,
disk);
}
}

bool partition_balancer_planner::request_context::all_reports_received() const {
Expand Down Expand Up @@ -539,6 +554,11 @@ class partition_balancer_planner::moving_partition {
if (node_it != _ctx.node_disk_reports.end()) {
node_it->second.released += sizes.get_current(
bs.node_id);
vlog(
clusterlog.trace,
"after cancelling, node id {} disk: {}",
node_it->first,
node_it->second);
}
}
}
Expand Down Expand Up @@ -950,6 +970,12 @@ partition_balancer_planner::reassignable_partition::move_replica(
auto from_it = _ctx.node_disk_reports.find(replica);
if (from_it != _ctx.node_disk_reports.end()) {
from_it->second.released += _sizes.get_current(replica);

vlog(
clusterlog.trace,
"after scheduling move, node id {} disk: {}",
from_it->first,
from_it->second);
}

auto to_it = _ctx.node_disk_reports.find(new_node);
Expand All @@ -959,6 +985,12 @@ partition_balancer_planner::reassignable_partition::move_replica(
} else {
to_it->second.assigned += _sizes.non_reclaimable;
}

vlog(
clusterlog.trace,
"after scheduling move, node id {} disk: {}",
to_it->first,
to_it->second);
}
}

Expand Down Expand Up @@ -986,6 +1018,12 @@ void partition_balancer_planner::reassignable_partition::revert(
if (from_it != _ctx.node_disk_reports.end()) {
from_it->second.released -= _sizes.get_current(
move.previous()->node_id);

vlog(
clusterlog.trace,
"after reverting move, node id {} disk: {}",
from_it->first,
from_it->second);
}

auto to_it = _ctx.node_disk_reports.find(move.current().node_id);
Expand All @@ -996,6 +1034,12 @@ void partition_balancer_planner::reassignable_partition::revert(
} else {
to_it->second.assigned -= _sizes.non_reclaimable;
}

vlog(
clusterlog.trace,
"after reverting move, node id {} disk: {}",
to_it->first,
to_it->second);
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/v/cluster/partition_balancer_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "model/metadata.h"
#include "model/timestamp.h"
#include "serde/serde.h"
#include "utils/human.h"
#include "utils/to_string.h"

#include <absl/container/btree_set.h>
Expand Down Expand Up @@ -45,6 +46,21 @@ struct node_disk_space {
double final_used_ratio() const {
return double(used + assigned - released) / total;
}

friend std::ostream& operator<<(std::ostream& o, const node_disk_space& d) {
fmt::print(
o,
"{{total: {}, used: {}, assigned: {}, released: {}; "
"used ratios: orig: {:.4}, peak: {:.4}, final: {:.4}}}",
human::bytes(d.total),
human::bytes(d.used),
human::bytes(d.assigned),
human::bytes(d.released),
d.original_used_ratio(),
d.peak_used_ratio(),
d.final_used_ratio());
return o;
}
};

struct partition_balancer_violations
Expand Down

0 comments on commit 01493a3

Please sign in to comment.