Skip to content

Commit 1a7023c

Browse files
committed
config, tablets: Allow tablets_initial_scale_factor to be a fraction
We may want fewer than 1 tablets per shard in large clusters. The per-table option is a fraction, so for consistency, this should be too.
1 parent 2b2fa02 commit 1a7023c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

db/config.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public:
502502
named_value<int> maximum_replication_factor_warn_threshold;
503503
named_value<int> maximum_replication_factor_fail_threshold;
504504

505-
named_value<int> tablets_initial_scale_factor;
505+
named_value<double> tablets_initial_scale_factor;
506506
named_value<unsigned> tablets_per_shard_goal;
507507
named_value<uint64_t> target_tablet_size_in_bytes;
508508

service/tablet_allocator.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class load_balancer {
597597
load_balancer_stats_manager& _stats;
598598
std::unordered_set<host_id> _skiplist;
599599
bool _use_table_aware_balancing = true;
600-
int _initial_scale = 1;
600+
double _initial_scale = 1;
601601
private:
602602
tablet_replica_set get_replicas_for_tablet_load(const tablet_info& ti, const tablet_transition_info* trinfo) const {
603603
// We reflect migrations in the load as if they already happened,
@@ -707,7 +707,7 @@ class load_balancer {
707707
_use_table_aware_balancing = use_table_aware_balancing;
708708
}
709709

710-
void set_initial_scale(int initial_scale) {
710+
void set_initial_scale(double initial_scale) {
711711
_initial_scale = initial_scale;
712712
}
713713

@@ -1092,7 +1092,6 @@ class load_balancer {
10921092
size_t tablet_count = 0;
10931093
const sstring* winning_dc = nullptr;
10941094

1095-
min_per_shard_tablet_count = std::max(1.0, min_per_shard_tablet_count);
10961095
for (auto&& [dc, shards_in_dc] : shards_per_dc) {
10971096
auto rf_in_dc = rs.get_replication_factor(dc);
10981097
if (!rf_in_dc) {

test/boost/tablets_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,6 +2678,12 @@ SEASTAR_THREAD_TEST_CASE(test_tablet_option_and_config_changes) {
26782678
cfg.tablets_per_shard_goal(100);
26792679
rebalance_tablets(e, &load_stats);
26802680
BOOST_REQUIRE_EQUAL(get_tablet_count(), 16);
2681+
2682+
// initial scale can be smaller than 1.
2683+
// 0.5 tablet/shard * 3 shards = 1.5 tablets =~ 2 tablets.
2684+
cfg.tablets_initial_scale_factor(0.5);
2685+
rebalance_tablets(e, &load_stats);
2686+
BOOST_REQUIRE_EQUAL(get_tablet_count(), 2);
26812687
}, cfg).get();
26822688
}
26832689

0 commit comments

Comments
 (0)