<@U0A71G31CDV> I’m running into tablet balancing i...
# questions-and-troubleshooting
d
@Rocky I’m running into tablet balancing issue. I have a cluster of 20 nodes and a table with 30 tablets (1 tablet per daily partition). They all ended up on one node in the cluster, so query across 30 daily partitions is hitting one node in the cluster instead of spreading out to 20 nodes. How do I solve this? I’m running 4.1.8 shared-data cluster.
r
First, tell apart two different problems A. Placement — the 30 shards really are all assigned to one CN. B. Scan parallelism — placement may be fine, but 30 tablets can't spread over 20 nodes anyway. Check placement first:
Copy code
sql
SHOW COMPUTE NODES;   -- TabletNum per node
SELECT BE_ID, count(*) FROM information_schema.be_tablets
WHERE TABLE_ID = <id> GROUP BY BE_ID;
SHOW TABLET FROM db.tbl;   -- BackendId column
If
TabletNum
is 30 on one node and ~0 elsewhere, it's A. If it's spread out but your query is still slow, it's B (or a cache/compaction issue — see the shared-data FAQ on slow queries). A. Balancing knobs for shared-data (4.1) Placement is owned by StarMgr/StarOS inside the FE, driven by these mutable FE configs: •
lake_enable_balance_tablets_between_workers
— default
true
. •
lake_balance_tablets_threshold
— default `0.15`; balancing triggers when
(MAX(tablets) - MIN(tablets)) / AVERAGE(tablets)
exceeds it. •
tablet_sched_disable_balance
— default `false`; also handed to StarMgr as the switch disabling its background shard checks. With your numbers (20 nodes, 30 tablets) the imbalance factor is roughly
(30-0)/1.5 = 20
, far above
0.15
, so a healthy balancer should be moving shards. If nothing moves, verify
lake_enable_balance_tablets_between_workers=true
and
tablet_sched_disable_balance=false
first. One caveat I can't fully resolve for you: there's a documented known issue where "replicas drift out of place after scale-out or warmup, and tablet balancing is slow", fixed in 4.0.11 by a bundled StarOS upgrade, with no backport listed for 4.1 or 3.5. On 4.1.8 you'd still have the old StarOS component. So if the configs are right and tablets simply don't move, this looks like that bug — the docs don't say which tablets StarMgr moves or how fast, and there's no SQL statement to pin or force-move a tablet. That's a case to raise on GitHub / community Slack with
SHOW COMPUTE NODES
and
information_schema.be_tablets
output. B. 30 tablets is too few for 20 nodes — fix bucketing too Even perfectly balanced, 30 tablets over 20 nodes = 1–2 tablets per node, so scan parallelism is capped at 30 regardless. And a single tablet is scanned by one CN (intra-tablet parallelism via
enable_tablet_internal_parallel
, default
true
, splits it into segments on that node — it does not spread the tablet across nodes). For 4.1 shared-data with large-capacity tablets, the docs recommend 10–50 GB per tablet, max 100 GB. Size your buckets from the daily partition size rather than thinking in "1 tablet per partition": • New partitions, keep them auto-sized and StarRocks infers per-partition:
ALTER TABLE t DISTRIBUTED BY HASH(k) DEFAULT BUCKETS n;
(or just omit BUCKETS at partition creation with
enable_auto_tablet_distribution=true
). Note auto-inference uses node count including CNs, so a daily partition created now in a 20-CN cluster will get ~30 buckets by default. • Existing partitions:
ALTER TABLE t PARTITIONS (p1, p2, ...) DISTRIBUTED BY HASH(k) BUCKETS n;
— an async rewrite job. Pause loads while it runs: there's a known issue where a concurrent load with
ALTER ... DISTRIBUTED BY
reports FINISHED but loses rows (PR 77754, merged on branch-4.1 but not yet released as of the docs I have). • Also watch the 4.1 range-distribution/auto split-merge path: auto-merge could merge small tablets back if partitions are small relative to
tablet_reshard_target_size
× CN count. That specific churn bug was fixed in 4.1.2, so 4.1.8 is fine there. Also check bucket-key skew — if the hash key is skewed, even enough buckets land on few nodes (the shared-data FAQ calls out "poor bucketing or skewed bucket keys cause queries to run on only a subset of nodes").
Suggested order: confirm placement → check the two balance configs → if unloading is stuck, treat as the StarOS drift issue and ask maintainers → regardless, raise bucket count per partition to hit 10–50 GB/tablet, which is what actually buys you 20-node parallelism for those 30 daily partitions. I'm not fully certain which of A or B is dominating on your cluster — the two checks above will tell you, and if you paste the
SHOW COMPUTE NODES
TabletNum
column and
SHOW PARTITIONS
bucket counts I can be more specific. References • administration/configuration/FE_parameters/stats_storage.md • faq/shared_data_faq.md • administration/configuration/FE_parameters/shared_lake_other.md • faq/operation_maintenance_faq.md • knowledge/qa/shared_data_cn_scheduling_and_tablet_mapping.md (StarRocks knowledge base) • knowledge/known_issues/shared_data.md (StarRocks knowledge base)
d
@Rocky There are 20k tablets per node in general. It just happened so that table placed on one node. So overall it’s “balanced” just not this table tablets.
r
Right — that reframes it. StarMgr's balancer is count-based over total tablets per worker, not per-table or per-partition. From the docs:
lake_balance_tablets_threshold
(default
0.15
) triggers a balance when
f = (MAX(tablets) - MIN(tablets)) / AVERAGE(tablets)
exceeds it — and the criterion is explicitly "tablet count, not data size or query load". With ~20k tablets per node, 30 extra tablets on one worker moves
f
by roughly
30/20000 ≈ 0.0015
, i.e. ~100× below the trigger. So the situation is self-consistent: the cluster is balanced by the only metric that exists, and this table's placement is invisible to it. There's also no statement to move or pin a tablet — I searched and found none; placement is StarOS-owned and the FE only reads the mapping at query time. What actually fixes it: more tablets, not relocation Until you add tablets, a cross-partition query can use at most 30 scans, i.e. 1–2 per node even if placement were perfect. So the fix is both placement and parallelism: Raise buckets per partition. Docs recommend 10–50 GB per tablet for 4.1 shared-data (max 100 GB); the shared-data FAQ gives
total data size / (1–5 GB)
. Picking a number divisible into a spread over 20 nodes helps (e.g. 10 buckets × 30 partitions = 300 tablets ≈ 15 per node, versus 1.5 today). • New partitions only:
ALTER TABLE t DISTRIBUTED BY HASH(k) DEFAULT BUCKETS 10;
(v3.5.8/4.0.1+, synchronous, no rewrite), or omit
BUCKETS
at
ADD PARTITION
under
enable_auto_tablet_distribution=true
. • Existing partitions:
ALTER TABLE t PARTITIONS (p1, p2, ...) DISTRIBUTED BY HASH(k) BUCKETS 10;
⚠️ Two caveats I want to be straight about: • The docs page on "Optimize data distribution after table creation" carries a notice that shared-data mode does not support this feature, while the ALTER TABLE reference and the offline-rewrite path suggest shared-data tables go through the offline job. That conflict is real in the docs — test on one partition first and check
SHOW ALTER TABLE
before doing all 30. • There is a known issue where a load concurrent with
ALTER ... DISTRIBUTED BY
reports FINISHED but loses rows (PR 77754; merged on branch-4.1, not yet in a release as far as I can see). Pause loads during the rewrite. Then let placement follow. Newly created tablets are what the balancer can actually spread. Increase
tablet_sched_max_balancing_tablets
(default 500, alias
max_balancing_tablets
) only if you see scheduling saturate. Things I would not rely on • Lowering
lake_balance_tablets_threshold
to ~0.001
would theoretically make the balancer start equalising counts at your 20k scale, but it's count-based and untargeted — it doesn't know about this table, and it would churn constantly. That's my inference from the formula, not something the docs endorse; I'd only try it on a test cluster. • Colocate groups mirror one bucket→node mapping across tables; they don't spread a single table's buckets beyond what round-robin gives you, and the docs describe placement logic that assumes a group is uniformly placed. Not a fix for 30 buckets. If tablets still don't move The known issue "replicas drift out of place after scale-out or warmup, and tablet balancing is slow" is fixed in 4.0.11 via a bundled StarOS upgrade, with no backport listed for 4.1 — so 4.1.8 may still carry the older StarOS. If the
ALTER
completes and the 300 tablets still land on one node, that's worth a GitHub issue with
SHOW COMPUTE NODES
and
SHOW TABLET FROM db.tbl
. Do you know the per-day partition data size? That determines whether 10 buckets is the right number or overkill for you. References • administration/management/resource_management/Replica.md • administration/configuration/FE_parameters/shared_lake_other.md
• knowledge/qa/shared_data_cn_scheduling_and_tablet_mapping.md (StarRocks knowledge base) • knowledge/known_issues/shared_data.md (StarRocks knowledge base) • faq/shared_data_faq.md • faq/operation_maintenance_faq.md
d
@Rocky per day data size is already below 10Gb, hence why it’s in 1 tablet. Adding hash bucket helps - but that creates lots of small tablets, which docs don’t recommend.
r
Your numbers do put you in a genuine bind: 10 GB/day sits exactly at the docs' floor for shared-data 4.1 ("10 GB to 50 GB per tablet, no more than 100 GB"), so 1 bucket/day is compliant — but 30 compliant tablets can only ever occupy 30 of 20 nodes, and right now they're on 1. Worth questioning the "small tablets" fear, with actual numbers The anti-small-tablet guidance is about avoiding metadata and small-file explosions at cluster scale. The concrete red flag in the docs is more than 200k tablets per BE. You have ~20k/node now. Going from 30 to 300 tablets for this table is 0.15% of that budget — it will not move you toward the problem the guidance is warning about. What it does cost, honestly: • ~1 GB tablets are below the shared-data 4.1 recommendation (general bucketing guidance is 1–10 GB/bucket, so you'd be at the bottom edge, not wildly out). • In shared-data each tablet has a metadata file in object storage, and more small files degrade performance until compaction merges them — the docs list "too many buckets" as a cause of excessive small files. So the trade is: 300 smallish tablets on 20 nodes vs. 30 well-sized tablets on 1 node. For a query that scans all 30 partitions, the first is clearly better. Rough sizing:
bucket_size ≈ partition_size / target_nodes_involved
. 4 buckets → ~2.5 GB each, 120 tablets, ~6/node. 8 buckets → ~1.25 GB, 240 tablets, ~12/node. The alternative paths and why they likely don't apply to you •
ALTER TABLE ... SPLIT TABLETS
(4.1, splits by
tablet_reshard_target_size
, default 10 GB) — but `MERGE TABLETS`/the reshard job factory only accepts range-distributed shared-data tables, which needs FE config
enable_range_distribution
(default
false
on 4.1). Your HASH-bucketed table won't take this path. Also splitting a 10 GB tablet at a 10 GB target does nothing for you anyway — you'd need a smaller target, which is just manual bucketing by another name. • Coarser partitions (merge daily → monthly, 3.5+): 30 → 1 partition of ~10 GB is still 1 tablet. Makes it worse for parallelism. • Balancer: count-based at 20k/node, so 30 extra tablets are invisible (
f ≈ 0.0015
vs a 0.15 threshold). No pin/move statement exists. So
ALTER TABLE ... PARTITIONS (...) DISTRIBUTED BY HASH(k) BUCKETS n
is the only real lever. Two caveats before you run it 1. The docs contradict themselves on whether shared-data tables support bucketing changes after creation ("Optimize data distribution after table creation" says shared-data is unsupported; the ALTER TABLE reference and offline-rewrite path suggest it works). Try one partition, check
SHOW ALTER TABLE
, then do the rest. 2. Known row-loss issue when a load runs concurrently with
ALTER ... DISTRIBUTED BY
reports FINISHED but drops rows (PR 77754, merged on branch-4.1 but not yet released). Pause loads. I can't confirm from the docs whether the 4.1 background split/merge daemon would later merge your 4–8 small buckets back toward
tablet_reshard_target_size
(10 GB). The known churn issue is described for range-distribution tables, so a HASH table shouldn't be in scope — but I'd verify with
information_schema.tablet_reshard_jobs
after the rewrite rather than assume. If you'd rather not touch the table: confirm first that the single-node placement is what's actually hurting, via the query profile (
CompressedBytesReadRemote
,
IOTimeRemote
) — with 10 GB/day the whole 30-day scan is ~300 GB, and one CN scanning that serializes both CPU and that node's data cache. Note
enable_lake_tablet_internal_parallel
(default true) splits a tablet into segments within the one CN holding it — it does not spread a tablet across nodes, so it won't rescue you here. References • administration/configuration/FE_parameters/stats_storage.md • knowledge/qa/bucket_number_and_small_tablets.md (StarRocks knowledge base)
• knowledge/known_issues/shared_data.md (StarRocks knowledge base) • table_design/data_distribution/Data_distribution.md • administration/configuration/BE_parameters/stats_storage.md • knowledge/qa/shared_data_cn_scheduling_and_tablet_mapping.md (StarRocks knowledge base)