tablets: Change the meaning of initial_scale to mean min-avg-tablets-per-shard
Currently the scale is applied post rounding up of tablet count so that tablet count per shard is at least 1. In order to be able to use the scale to increase tablet count per shard, we need to apply it prior to division by RF, otherwise we will overshoot per-shard tablet replica count. Example: 4 nodes, -c1, rf=3, initial_tablets_scale=10 Before: initial_tablet_count=20, tablet-per-shard=15 After: initial_tablet_count=14, tablets-per-shard=10.5
This commit is contained in:
@@ -1334,7 +1334,8 @@ db::config::config(std::shared_ptr<db::extensions> exts)
|
||||
, minimum_replication_factor_warn_threshold(this, "minimum_replication_factor_warn_threshold", liveness::LiveUpdate, value_status::Used, 3, "")
|
||||
, maximum_replication_factor_warn_threshold(this, "maximum_replication_factor_warn_threshold", liveness::LiveUpdate, value_status::Used, -1, "")
|
||||
, maximum_replication_factor_fail_threshold(this, "maximum_replication_factor_fail_threshold", liveness::LiveUpdate, value_status::Used, -1, "")
|
||||
, tablets_initial_scale_factor(this, "tablets_initial_scale_factor", value_status::Used, 10, "Calculated initial tablets are multiplied by this number")
|
||||
, tablets_initial_scale_factor(this, "tablets_initial_scale_factor", value_status::Used, 10,
|
||||
"Minimum average number of tablet replicas per shard per table. Suppressed by tablet options in table's schema: min_per_shard_tablet_count and min_tablet_count")
|
||||
, target_tablet_size_in_bytes(this, "target_tablet_size_in_bytes", liveness::LiveUpdate, value_status::Used, service::default_target_tablet_size,
|
||||
"Allows target tablet size to be configured. Defaults to 5G (in bytes). Maintaining tablets at reasonable sizes is important to be able to " \
|
||||
"redistribute load. A higher value means tablet migration throughput can be reduced. A lower value may cause number of tablets to increase significantly, " \
|
||||
|
||||
@@ -336,11 +336,13 @@ future<size_t> network_topology_strategy::calculate_min_tablet_count(schema_ptr
|
||||
if (tablet_options.expected_data_size_in_gb) {
|
||||
tablet_count = std::max<size_t>(tablet_count, (tablet_options.expected_data_size_in_gb.value() << 30) / target_tablet_size);
|
||||
}
|
||||
if (tablet_options.min_per_shard_tablet_count) {
|
||||
tablet_count = std::max<size_t>(tablet_count, calculate_initial_tablets_from_topology(*s, tm, _dc_rep_factor, tablet_options.min_per_shard_tablet_count.value()));
|
||||
}
|
||||
if (tablet_count == 0) {
|
||||
tablet_count = co_await calculate_initial_tablets_from_topology(*s, tm, _dc_rep_factor) * initial_scale.value_or(1);
|
||||
auto min_per_shard_tablet_count = tablet_options.min_per_shard_tablet_count.value_or(
|
||||
// If min_tablet_count is set, initial_scale should not be effective for
|
||||
// compatibility with the deprecated "initial" tablet count.
|
||||
(get_initial_tablets() || tablet_options.min_tablet_count) ? 0 : initial_scale.value_or(1));
|
||||
if (min_per_shard_tablet_count) {
|
||||
tablet_count = std::max<size_t>(tablet_count, co_await calculate_initial_tablets_from_topology(*s, tm, _dc_rep_factor,
|
||||
min_per_shard_tablet_count));
|
||||
}
|
||||
co_return tablet_count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user