<@U0A71G31CDV> I could see so many times the same ...
# questions-and-troubleshooting
m
@Rocky I could see so many times the same error lines like 2026-08-10 001225.842+05:30 ERROR (publish-task-427182|2007279) [PublishVersionDaemon.publishPartition():983] Fail to publish partition 282528 of txn 7793157: Fail to publish version for tablets:[[282529]], error msg: The previous publish version task for tablet 282529 has not finished. You can ignore this error and the task will retry later., host: starrocks-cn-1.starrocks-cn-search.starrocks-shared.svc.cluster.local what might be happening? the cn-1 is not doing anything but query fragments going to cn-1, and became normal after restarting cn-1.
✅ 1
r
The error message
The previous publish version task for tablet ... has not finished
typically occurs in shared-data (compute-node-based) clusters. It indicates that the Frontend (FE) tried to issue a new "publish version" task to a specific Compute Node (CN), but that CN still has an earlier task running for the same tablet. What is likely happening? 1. Task Hang or Slow Execution: A previous task for that tablet is either stuck or taking an exceptionally long time to complete. This can be caused by slow communication with object storage (S3/OSS), large amounts of metadata to process, or a high volume of small files. 2. Resource Contention: If the CN is under heavy load or the publish version thread pool is exhausted, tasks may queue up or execution may slow down, leading to overlaps. 3. Known Bugs: This specific log pattern has been associated with bugs in certain versions (e.g., v3.2.x, v3.3.x) where metadata operations or compaction tasks could hang or fail to clean up their state properly. Why did restarting CN-1 fix it? Restarting the CN clears its in-memory "task registry." When the CN starts fresh, it no longer believes there is an "active" task for that tablet, allowing the FE to successfully issue the next publish request. Troubleshooting & Recommendations To identify the root cause, you can perform the following checks: 1. Check CN Logs: Inspect the
<http://cn.INFO|cn.INFO>
or
<http://be.INFO|be.INFO>
logs on
starrocks-cn-1
around the time of the error. Look for errors related to
lake_service
,
tablet_manager
, or S3/object storage timeouts. 2. Check Compaction Status: Sometimes a stuck compaction can block the publish version process.
Copy code
sql
    SHOW PROC '/compactions';
Look for any partitions or tablets that have two compaction transactions with an empty
FinishTime
. 3. Check Version: What StarRocks version are you running? • If you are on an older version (e.g., v3.2.x or early v3.3.x), there are known fixes in later patch releases (like v3.3.10+ or v3.2.11+) specifically for publish/compaction hangs in shared-data mode. 4. Monitor Thread Pools: Check the publish version queue count to see if the CN is struggling to keep up:
Copy code
sql
    -- In the CN metrics (typically at port 8040/metrics)
    starrocks_be_publish_version_queue_count
5. Check Object Storage: Ensure there are no latency issues or permission errors with your object storage (S3/OSS), as the "publish" step in shared-data mode involves finalizing metadata files in the cloud-side. Next Step: If this recurs, please provide your StarRocks version and snippets from the CN-1 logs (
<http://cn.INFO|cn.INFO>
) around the time the error starts. References • deployment/upgrade.md • deployment/downgrade.md • introduction/versioning.md • faq/Deploy_faq.md • release_notes/release-3.3.md • release_notes/release-3.2.md • release_notes/release-2.3.md
m
I'm using 4.0.8 version, the logs is there from 11:00 to 12:12. @Rocky
r
In StarRocks v4.0.8 (Shared-data mode), the error
The previous publish version task for tablet ... has not finished
indicates a task-level deadlock or hang on the Compute Node (CN). In a shared-data architecture, the Frontend (FE) coordinates with the CN to finalize data versions (Publish Version). Each tablet can only have one active publish task at a time. If the FE attempts to start a new publish task while the CN still believes an older one for the same tablet is running, it returns this error. Likely Causes for the 11:00 – 12:12 Window 1. Stuck Publish/Compaction RPCs: A previous metadata operation (often related to Compaction or a high-frequency Load) may have hung. This usually happens if the CN is waiting on a response from object storage (S3/OSS) or if a thread in the
lake_service
became unresponsive. 2. Object Storage Latency: Since shared-data metadata is written to the object store, any "blips" or high latency in your S3/OSS provider during that 1-hour window could cause publish tasks to exceed their internal timeouts but remain "active" in the CN's memory. 3. Metadata Cache Inconsistency: In v4.0.x, StarRocks utilizes aggressive metadata caching. If a task fails to clear its "running" state due to a localized CN error, it will block all subsequent publish attempts for that tablet until the CN is restarted. Troubleshooting Steps If this happens again, run these checks before restarting the CN: * Check for Stuck Compactions: Often, a stuck compaction task is what blocks the version publish. Run:
Copy code
sql
    SHOW PROC '/compactions';
Look for tasks where the
FinishTime
is empty and the
StartTime
is over an hour old. * Inspect CN Logs for RPC Timeouts: Search the
<http://cn.INFO|cn.INFO>
log on
starrocks-cn-1
specifically for: *
lake_service
errors *
RPC timeout
or
Deadline Exceeded
*
fail to put object
(indicating S3/OSS write issues) * Monitor Publish Queue: Check the CN metrics (typically
http://<cn_ip>:8040/metrics
) for:
Copy code
text
    starrocks_be_publish_version_queue_count
If this count is high, the CN is likely bottlenecked by I/O or CPU, preventing it from clearing tasks. Recommended Actions 1. Upgrade to v4.1+ (if available): Version 4.1 introduced several "Built for Production" stability fixes for tablet management and better handling of stale tasks. 2. Increase Worker Threads: If you have high ingestion concurrency, you might need to increase the publish worker threads in `cn.conf`:
Copy code
conf
    transaction_publish_version_worker_count = 0 (defaults to CPU cores, ensure it's not restricted)
3. Audit Object Storage: Check your cloud provider's metrics for the
11:00 to 12:12
period to see if there were any 5xx errors or increased latency for
PutObject
or
PostObject
calls. References • administration/management/monitoring/metrics.md • administration/management/BE_configuration.md • administration/management/FE_configuration.md • faq/loading/Loading_faq.md • faq/Sql_faq.md
m
@Rocky could see egress bandwidth usage is high during this time compared to other times. does it block the queries on that compute node as well incase of this issue?
r
Yes, high egress bandwidth can definitely block or severely degrade both the Publish Version process and active queries on that Compute Node (CN). In StarRocks v4.0.x (Shared-data mode), here is how high egress bandwidth likely caused your specific scenario: 1. How Egress Saturation Blocks "Publish Version" In shared-data mode, when a load transaction finishes, the CN must publish the new version by writing metadata files to your object storage (S3/OSS/GCS). * Egress Usage: This metadata write is outgoing traffic (egress). * The Hang: If your egress bandwidth is saturated (e.g., by a massive query result, data export, or shuffle), the metadata write to S3 may experience high latency or RPC timeouts. * The Error: The CN marks the task as "started" but never receives a completion signal from the object store. Subsequent publish attempts for the same tablet see the "previous task has not finished" state and fail with the error you saw. 2. Does it block queries? Yes, for several reasons: * Network Congestion (RPC Latency): StarRocks relies heavily on internal RPCs to move data between nodes (Shuffle/Broadcast). If egress is saturated, the CN cannot send query results to other nodes or the FE efficiently. This causes "Pipeline" execution threads to hang, eventually leading to
Query exceeded timeout
or
The server is overcrowded
errors. * Version Stall: While queries can technically read the old visible version while a new one is being published, if the "Publish Version" is stuck for a long time, users will notice that newly loaded data is not appearing in their queries. * Resource Contention: High egress is often a symptom of high I/O or CPU usage (e.g., a massive
SELECT *
or
INSERT INTO...SELECT
). This resource contention slows down the background threads responsible for metadata management and tablet health checks. Why did the restart fix it? * State Reset: It forcefully killed the "stuck" publish tasks that were waiting for network responses that would never come. * Queue Clearing: It cleared the
brpc
and transmission buffers that were likely backed up due to the egress spike. * Connection Refresh: It reset the connection pool to your object storage. Recommendations to prevent recurrence: 1. Check for "Heavy" Queries: Look for queries around 11:00 that might have been pulling massive amounts of data (e.g., large
EXPORT
jobs or
SELECT
without filters). 2. Bandwidth Monitoring: If your egress is hitting the physical limit of your VM or network interface, consider increasing the instance size (more bandwidth) or limiting query concurrency. 3. Tune bRPC Buffers: If you frequently see high network load, you can increase the bRPC socket buffer in
cn.conf
(requires restart):
Copy code
conf
    brpc_socket_max_unwritten_bytes = 1073741824  # Increase to 1GB or more if needed
4. Isolate Workloads: If possible, use Resource Groups to limit the maximum CPU/memory of heavy queries so they don't starve critical background tasks like "Publish Version." References • faq/Sql_faq.md • knowledge/trouble_shooting/fe_deadlock_problems.md
m
@Rocky I have resource group for ingestion load jobs limit to 20% max of cpu/memory. queries should not impact if this is only reosurce issue. how do I make sure this issue doesn't happen again like nodes blocking the queries(queries enterign node but not completing) and also see those busy nodes only reading so much of data(received max network GB data) compared to other compute nodes
r
To ensure this issue doesn't happen again and to address the data/network imbalance you're seeing on specific nodes, you need to look beyond just CPU and memory resource groups. 1. Why Resource Groups (20%) Didn't Prevent the "Block" Standard StarRocks Resource Groups limit CPU scheduling and Memory usage, but they do not natively throttle Network Bandwidth or Disk I/O. * The Network Bottleneck: If an ingestion job or a query is reading/writing massive amounts of data, it can saturate the CN's network interface (egress/ingress). * The "Block": When the network is saturated, the Publish Version RPC (which must talk to object storage) and Internal Shuffle (CN-to-CN communication) time out. The CN becomes "overcrowded," and even though it has CPU/Memory available, it cannot send or receive data packets, causing queries to hang. 2. How to Prevent "Stuck" Queries on Busy Nodes To prevent a single busy node from "swallowing" queries and never completing them: * Enable Query Queueing: Set a
concurrency_limit
on your resource groups. This prevents too many queries from entering the "execution" phase on a node simultaneously.
Copy code
sql
    ALTER RESOURCE GROUP your_group_name PROPERTIES ("concurrency_limit" = "10");
* Shorten Query Timeouts: If a node is truly saturated, it's better for a query to fail fast than to hang for an hour.
Copy code
sql
    SET GLOBAL query_timeout = 300; -- 5 minutes
* bRPC Socket Tuning: To prevent the "overcrowded" error where the internal communication buffer fills up due to network congestion, increase this in `cn.conf`:
Copy code
conf
    brpc_socket_max_unwritten_bytes = 2147483648 # Increase to 2GB
3. Fixing the Data/Network Imbalance If one node is "reading so much more data" (Received GB) than others, your data is likely skewed. * Check Tablet Distribution: Even in shared-data mode, tablets are "scheduled" to specific CNs for the duration of a query. If one node has many more "hot" tablets, it will handle more traffic.
Copy code
sql
    -- Check if one node has significantly more tablets than others
    SHOW PROC '/cluster_balance/tablet_num';
* Optimize Bucketing: If your
DISTRIBUTED BY
key has low cardinality (e.g., a "City" column where 80% of data is "New York"), all that data will hit the same tablets and thus the same CNs. Use a high-cardinality column (like
ID
) or multiple columns for the bucket key. * Data Cache Skew: In shared-data mode, the first node to read data caches it locally. If subsequent queries are all routed to the same node because of tablet affinity, that node will stay "busy" while others stay idle. Check your
Query Profile
for
CompressedBytesReadRemote
. If one node has high remote reads, it's pulling from S3/OSS instead of its local cache. 4. Making "Publish Version" Resilient To prevent the "Previous task not finished" error from hanging your ingestion pipeline: * Metadata Timeout (v4.0.x): Ensure the
retry_apply_timeout_second
is not set too high (default is 7200s/2hrs). You can lower it so the tablet enters an error state faster (which triggers a retry) rather than hanging in "Publishing" for 2 hours. * Worker Threads: If you have many tables being loaded at once, increase the threads that handle these tasks in `cn.conf`:
Copy code
conf
    transaction_publish_version_worker_count = 64 # Or 2x your CPU cores
Summary Checklist: 1. Check Skew: Run
SHOW TABLET FROM table_name
and look for size imbalances. 2. Monitor Network: If egress/ingress is hitting >80% of your VM's physical limit, you must either increase the instance size or throttle your ingestion/export frequency. 3. Audit Queries: Find the specific query in
information_schema.exec_queries
that ran during the 1100 1212 window with the highest
scan_bytes
. References
m
@Rocky I tried setting the logs to keep in cn for 1day but there are so many days logs , what configs all should I give to make sure only 1day logs are there
r
For the Compute Node (CN), log retention is handled differently than the Frontend (FE). The CN uses a Google-style logging system (glog) which does not support the
sys_log_delete_age
parameter. Instead, it relies on rotation mode and the number of files kept. To ensure you only keep approximately 1 day of logs in your
cn.conf
, you must set the following configurations: 1. Configure System Log Rotation (
<http://cn.INFO|cn.INFO>
,
cn.WARN
,
cn.ERROR
)
By default, logs rotate when they reach 1GB. If your logs are small, one file could contain many days of data. To force a daily rotation and limit the count: *
sys_log_roll_mode = TIME-DAY
: This forces the log to roll over every day, regardless of size. *
sys_log_roll_num = 1
: This tells StarRocks to only keep 1 "rolled" (archived) file in addition to the current active log. 2. Configure Ingestion Error Logs The logs for failed loads (stored in
storage/error_log
) are controlled by a separate time-based parameter: *
load_error_log_reserve_hours = 24
: This specifically deletes the import error logs after 24 hours. 3. Summary of
cn.conf
Settings
Add or update these lines in your `cn.conf`:
Copy code
conf
# Rotate logs every day
sys_log_roll_mode = TIME-DAY

# Keep only the current log and 1 historical day
sys_log_roll_num = 1

# Keep ingestion error logs for 24 hours
load_error_log_reserve_hours = 24
Important Notes: 1. Restart Required: These parameters are not "mutable" (dynamic). You must restart the CN process for them to take effect. 2. Manual Cleanup: Changing these settings will not automatically delete "old" logs that were created under the previous policy. Since the filenames of older logs might not match the new rotation pattern, you should manually delete the existing historical logs in your
log/
directory once after applying the new config. 3. FE vs CN: Ensure you are not accidentally using
sys_log_delete_age
(e.g.,
7d
) in the
cn.conf
. That parameter only works for the FE. References • administration/management/logs.md • administration/management/BE_configuration.md References • administration/management/FE_configuration.md • administration/management/BE_configuration.md • administration/management/logs.md
m
@Rocky on autoscaling down, is there a config that deregisters the compute node as well from FE?
r
Currently, there is no single configuration parameter (e.g., in
fe.conf
or
cn.conf
) that automatically deregisters/drops a Compute Node (CN) from the Frontend (FE) metadata upon scaling down. In StarRocks, nodes are registered in the FE's global metadata. When a CN process stops, the FE detects the heartbeat loss and marks it as
DEAD
(or
DISCONNECTED
), but the entry remains in the system until an explicit
DROP
command is issued. 1. How it works today: "Graceful Exit" StarRocks (v3.3+) supports Graceful Exit, which helps with stability but not metadata cleanup: * Behavior: When you run
./bin/stop_cn.sh -g
, the CN sends a signal to the FE to mark itself as
EXITING
. * Result: The FE immediately stops sending new query fragments to that node. Existing queries are allowed to finish within a timeout. * Limitation: After the process exits, the node will still appear in
SHOW COMPUTE NODES
with
Alive: false
. It is not automatically removed from the cluster metadata. 2. The Recommended Workaround (Kubernetes) If you are using Kubernetes and want nodes to be "cleaned up" from the FE during a scale-down event, the standard practice is to use a
preStop
hook
in your Pod manifest. This hook runs a script to tell the FE to drop the node before the container is destroyed. Example
preStop
hook logic:
Copy code
yaml
lifecycle:
  preStop:
    exec:
      command:
      - /bin/sh
      - -c
      - |
        # Use a mysql client to tell FE to drop this specific node
        mysql -h ${FE_HOST} -P ${FE_QUERY_PORT} -u root -e "ALTER SYSTEM DROP COMPUTE NODE \"${MY_POD_IP}:${HEARTBEAT_PORT}\";"
3. Why is there no auto-deregister config? StarRocks treats node membership as a "source of truth" in its metadata to prevent accidental data/metadata inconsistency. * If a node simply loses network for 1 minute, you wouldn't want the cluster to automatically "forget" it exists and re-plan the entire cluster state. * For BE (Backends), this is even more critical because they hold data. * For CN (Compute Nodes), while they are stateless, an automatic "drop" could lead to metadata churn if the network is unstable. Summary of what to do: 1. Manual Cleanup: If you scale down manually, run:
Copy code
sql
    ALTER SYSTEM DROP COMPUTE NODE "host:port";
2. Automation: If using autoscaling, implement the
preStop
hook
mentioned above or use a script that monitors for
Alive: false
nodes and prunes them periodically. 3. Check Blacklist Config: Ensure you are using the Blacklist feature (v3.3+) which can automatically exclude "bad" nodes from queries without dropping them, preventing query failures while the node is still technically in the metadata. References • administration/management/Scale_up_down.md • administration/management/graceful_exit.md • administration/management/BE_blacklist.md References • administration/management/BE_blacklist.md • administration/management/FE_configuration.md • administration/Meta_recovery.md
m
@Rocky is it recommened to add preStop in k8s pod for removing compute node? the problem is if it is there, I can see all logs related to that FQDN not able to reach .....
r
Using a
preStop
hook to
DROP COMPUTE NODE
is a common approach to keep your metadata clean, but it is not strictly recommended as a "best practice" for every scenario because it causes the exact side effects you are seeing (log noise and race conditions). Why you see "FQDN not able to reach" logs When you execute
DROP COMPUTE NODE
in a
preStop
hook, a race condition occurs: 1. RPC/Connection Pools: Even though the node is "dropped" from the FE's main list, other nodes (CNs and the FE) have active connection pools or cached routing tables. They may still try to send heartbeats or final query fragments to that FQDN for a few seconds. 2. Heartbeat Timing: The FE's heartbeat thread might attempt to ping the node at the exact microsecond the pod is shutting down, but before the
DROP
command has been fully processed and synchronized across all FE followers. 3. In-flight Queries: If a query was planned right before the
DROP
, the FE might still try to send a fragment to that node, failing with a "connection refused" or "cannot reach FQDN" error. The Recommended Alternative: Graceful Exit + Clean-up Script Instead of putting the
DROP
command inside the pod that is currently dying, follow this more stable pattern: 1. Use Graceful Exit (v3.3+) Ensure your
cn.conf
or your container's entrypoint is set up to handle
SIGTERM
gracefully. In StarRocks v3.3+, the CN will enter an
EXITING
state. * What happens: The FE sees the
EXITING
state and immediately stops scheduling new queries to that node. * Benefit: This prevents "connection refused" errors for new queries because the FE is aware the node is leaving before it actually disappears. * Kubernetes Tip: Increase the
terminationGracePeriodSeconds
in your YAML to give the CN enough time (e.g., 60-120s) to finish its tasks. 2. Separate "Pruning" Job Rather than the pod "killing itself" in the metadata, use a separate lightweight CronJob or a script in your CI/CD pipeline that periodically cleans up "Dead" nodes:
Copy code
sql
-- This script runs externally to the CN pods
DELETE FROM information_schema.compute_nodes WHERE alive = 'false';
-- Or more safely via a shell script:
# mysql -e "SHOW COMPUTE NODES" | grep 'false' | awk '{print "ALTER SYSTEM DROP COMPUTE NODE \""$1"\";"}' | mysql
This ensures the node is only dropped after it is truly gone and all network connections have naturally timed out, which significantly reduces log noise. If you MUST use
preStop
If your environment requires the node to be dropped immediately (e.g., very frequent autoscaling), try this sequence in your
preStop
to minimize errors: 1. Sleep:
sleep 5
(Let the FE stop sending new fragments). 2. Graceful Stop: Call
/starrocks/cn/bin/stop_cn.sh -g
. 3. Drop: Run the
ALTER SYSTEM DROP COMPUTE NODE
command. 4. Final Sleep:
sleep 5
(Allow metadata to propagate to all FE followers before the Pod is finally deleted). Summary Recommendation * For Rolling Upgrades: Do NOT use
DROP
. Let the node go
Offline
and come back
Online
to preserve metadata stability. * For Autoscaling (Scale Down): Use the Graceful Exit mechanism to stop traffic, then use an external process (like the StarRocks Operator or a maintenance script) to
DROP
the dead nodes 1-2 minutes later. This keeps your FE/CN logs clean of "unreachable FQDN" errors. References • administration/management/graceful_exit.md • deployment/sr_operator.md • administration/management/Scale_up_down.md References • administration/management/graceful_exit.md • administration/management/Scale_up_down.md
m
@Rocky how do I maintain cluster backup(FE metadata PVC) to restore if any corrpution happens?
r
To maintain a reliable backup of your StarRocks FE metadata on Kubernetes, you should use a multi-layered approach that combines native StarRocks checkpointing with infrastructure-level snapshots. 1. Native Metadata Checkpointing StarRocks automatically performs "checkpointing," where it saves the current state of the metadata into an image file (stored in
meta/image
). To ensure you have a fresh, consistent state before performing an external backup, you can manually trigger this:
Copy code
sql
-- Forces the Leader FE to create a new metadata image file
ALTER SYSTEM CREATE IMAGE;
* Why? This collapses the edit logs (journals) into a single file, making the metadata directory smaller and easier to restore. 2. Infrastructure Level: PVC Snapshots (Recommended) Since your metadata is on a K8s PVC, the most robust method is to use CSI Volume Snapshots. This is faster and more reliable than manual file copies. * Velero: Use Velero with the CSI plugin to back up the FE PVCs and the StarRocks cluster manifests (ConfigMaps, Services, etc.). * StorageClass Snapshots: If your cloud provider supports it, schedule periodic snapshots of the FE metadata PVs (e.g., every 4–24 hours). * Consistency Note: It is best to run
ALTER SYSTEM CREATE IMAGE
shortly before your scheduled K8s snapshot to ensure the snapshot contains a recent, compacted image file. 3. Application Level: Cluster Snapshots (v3.5+) If you are running StarRocks v3.5 or later in a shared-data (compute-storage separated) architecture, use the new Cluster Snapshot feature. * It captures the complete cluster state (catalogs, users, databases) and stores it directly in object storage (S3/GCS/HDFS). * This is the preferred way for modern deployments as it automates the backup of metadata to a location outside your K8s cluster. 4. Cold Backup (The "Safety Net") As a last resort, you can periodically copy the contents of the
meta/
directory from a Follower FE to an external location (like S3). * Caution: Never copy the
meta/
directory of a running Leader FE without an image creation, as the BerkeleyDB (BDB) files might be in an inconsistent state. It is safer to copy from a Follower or stop the pod briefly (if your quorum allows). How to Restore if Corruption Happens If your metadata becomes corrupted, the recovery process typically follows these steps: 1. Restore the PVC: Use Velero or your K8s snapshot to restore the FE metadata volumes to a known good state. 2. Reset Election (If needed): If the cluster cannot form a quorum because of the metadata loss, add this config to
fe.conf
before starting:
Copy code
conf
    bdbje_reset_election_group = true
This forces the node to become the new Leader. Remove this config immediately after a successful start. 3. Metadata Recovery Mode: If specific journals are bad, you can use:
Copy code
conf
    metadata_enable_recovery_mode = true
This allows the FE to start in a restricted mode to inspect and fix data. References • administration/Meta_recovery.md • administration/management/FE_configuration.md • quick_start/helm.md (Storage section) References • administration/Meta_recovery.md • administration/management/FE_configuration.md • quick_start/helm.md • faq/operation_maintenance_faq.md References • administration/Meta_recovery.md
m
@Rocky what is best way to move from restricted specified buckets of a table to starrocks manage buckets? removing buckets specifiicationin table
r
For StarRocks versions 3.2 and later, you can migrate an existing table to managed (automatic) buckets using a native
ALTER TABLE
command. For older versions, you must use the "recreate and swap" method. 1. For StarRocks v3.2 and newer (Recommended) You can directly modify the distribution of an existing table. By executing the
ALTER
command and omitting the
BUCKETS
keyword, StarRocks will automatically calculate the ideal number of buckets based on your cluster size and data volume. Syntax:
Copy code
sql
-- Change all existing partitions to use automatic bucketing
ALTER TABLE <table_name> DISTRIBUTED BY HASH(<column_names>);
* How it works: This triggers a background task to redistribute the data. You can monitor the progress using
SHOW ALTER TABLE COLUMN;
. * Result: All current partitions (and any new ones created later) will now be managed by StarRocks. ────────── 2. For StarRocks versions before v3.2 The
ALTER
command for distribution was introduced in v3.2. On older versions, you must follow the Create-Insert-Swap pattern: 1. Create a new table with the exact same schema, but omit the
BUCKETS
clause:
Copy code
sql
    CREATE TABLE table_new ( ... )
    DISTRIBUTED BY HASH(id); -- No BUCKETS specified here
2. Migrate the data:
Copy code
sql
    INSERT INTO table_new SELECT * FROM table_old;
3. Swap the tables atomically:
Copy code
sql
    ALTER TABLE table_old RENAME table_backup;
    ALTER TABLE table_new RENAME table_old;
────────── 3. Best Practices for "Managed" Buckets * Omit the keyword: For any new table creation, simply stop including
BUCKETS = <num>
. Since v2.5.7, StarRocks defaults to automatic bucketing if the clause is missing. * Dynamic Scaling (v3.2+): If you use Random Bucketing (common for Duplicate Key tables), you can enable "On-demand Dynamic Increasing" by setting a target bucket size rather than a count:
Copy code
sql
    PROPERTIES("bucket_size" = "1073741824") -- Aim for ~1GB per bucket
* Manual Override: If a single partition's raw data exceeds 100 GB, StarRocks documentation still suggests considering manual bucket counts for fine-tuned performance, though the automatic logic handles most standard production workloads (100MB–1GB per bucket) effectively. Summary of what to "remove" To move to StarRocks-managed buckets, you are essentially removing the
BUCKETS
property
from your DDL or
ALTER
statements. Goal | Command New Table |
DISTRIBUTED BY HASH(col)
(Stop there) Existing Table (3.2+) |
ALTER TABLE t1 DISTRIBUTED BY HASH(col);
Specific Partitions |
ALTER TABLE t1 PARTITIONS (p1, p2) DISTRIBUTED BY HASH(col);
References • table_design/data_distribution/Data_distribution.md • sql-reference/sql-statements/table_bucket_part_index/ALTER_TABLE.md References • table_design/data_distribution/Data_distribution.md • knowledge/usage/best-practice.md • sql-reference/sql-statements/table_bucket_part_index/ALTER_TABLE.md