Mohan
08/10/2026, 6:30 AMRocky
08/10/2026, 6:34 AMThe 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.
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:
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.mdMohan
08/10/2026, 6:39 AMRocky
08/10/2026, 6:40 AMThe 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:
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:
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`:
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.mdMohan
08/10/2026, 6:56 AMRocky
08/10/2026, 6:56 AMQuery 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):
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.mdMohan
08/10/2026, 7:06 AMRocky
08/10/2026, 7:06 AMconcurrency_limit on your resource groups. This prevents too many queries from entering the "execution" phase on a node simultaneously.
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.
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`:
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.
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`:
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.
ReferencesRocky
08/10/2026, 7:06 AMMohan
08/10/2026, 7:12 AMRocky
08/10/2026, 7:13 AMsys_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`:
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.mdMohan
08/10/2026, 8:29 AMRocky
08/10/2026, 8:30 AMfe.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:
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:
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.mdMohan
08/10/2026, 8:33 AMRocky
08/10/2026, 8:34 AMpreStop 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:
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.mdRocky
08/10/2026, 8:34 AMMohan
08/10/2026, 8:39 AMRocky
08/10/2026, 8:39 AMmeta/image). To ensure you have a fresh, consistent state before performing an external backup, you can manually trigger this:
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:
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:
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.mdMohan
08/10/2026, 10:57 AMRocky
08/10/2026, 10:57 AMALTER 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:
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:
sql
CREATE TABLE table_new ( ... )
DISTRIBUTED BY HASH(id); -- No BUCKETS specified here
2. Migrate the data:
sql
INSERT INTO table_new SELECT * FROM table_old;
3. Swap the tables atomically:
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:
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