github-actions[bot] commented on code in PR #62596:
URL: https://github.com/apache/doris/pull/62596#discussion_r3108107003
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudEnv.java:
##########
@@ -489,4 +499,57 @@ protected void cloneClusterSnapshot() throws Exception {
this.cloudSnapshotHandler.cloneSnapshot(this.clusterSnapshotFile);
}
}
+
+ @Override
+ public void compactTable(String dbName, String tableName, String type,
List<String> partitionNames)
+ throws DdlException {
+ Database db = getInternalCatalog().getDbOrDdlException(dbName);
+ OlapTable olapTable = db.getOlapTableOrDdlException(tableName);
+
+ AgentBatchTask batchTask = new AgentBatchTask();
+ int dispatchedCount = 0;
+ olapTable.readLock();
+ try {
+ LOG.info("Cloud table compaction. db={}, table={}, partitions={},
type={}",
+ dbName, tableName, partitionNames, type);
+ for (String parName : partitionNames) {
+ Partition partition = olapTable.getPartition(parName);
+ if (partition == null) {
+ throw new DdlException("partition[" + parName + "] not
exist in table[" + tableName + "]");
+ }
+
+ for (MaterializedIndex idx :
partition.getMaterializedIndices(IndexExtState.VISIBLE)) {
+ for (Tablet tablet : idx.getTablets()) {
+ // Cloud: each tablet has only one CloudReplica
(primary BE). The backend
+ // resolution depends on the current compute group
(ConnectContext); skip
+ // the tablet rather than aborting so other tablets
can still dispatch.
+ for (Replica replica : tablet.getReplicas()) {
+ long beId;
Review Comment:
`replica.getBackendId()` is not a pure metadata lookup in cloud mode.
`CloudReplica.getBackendId()` goes through `getCloudClusterIdByName()`, which
can call `CloudSystemInfoService.waitForAutoStart()` and block on Meta Service
/ retry sleeps while the compute group is being resumed. Because this happens
under `olapTable.readLock()`, a suspended or recovering compute group can hold
the table metadata lock for a long time and block unrelated operations on the
same table. Please snapshot the partitions/tablets you need under the read
lock, release it, and only then resolve backend ids / build agent tasks.
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudEnv.java:
##########
@@ -489,4 +499,57 @@ protected void cloneClusterSnapshot() throws Exception {
this.cloudSnapshotHandler.cloneSnapshot(this.clusterSnapshotFile);
}
}
+
+ @Override
+ public void compactTable(String dbName, String tableName, String type,
List<String> partitionNames)
+ throws DdlException {
+ Database db = getInternalCatalog().getDbOrDdlException(dbName);
+ OlapTable olapTable = db.getOlapTableOrDdlException(tableName);
+
+ AgentBatchTask batchTask = new AgentBatchTask();
+ int dispatchedCount = 0;
+ olapTable.readLock();
+ try {
+ LOG.info("Cloud table compaction. db={}, table={}, partitions={},
type={}",
+ dbName, tableName, partitionNames, type);
+ for (String parName : partitionNames) {
+ Partition partition = olapTable.getPartition(parName);
+ if (partition == null) {
+ throw new DdlException("partition[" + parName + "] not
exist in table[" + tableName + "]");
+ }
+
+ for (MaterializedIndex idx :
partition.getMaterializedIndices(IndexExtState.VISIBLE)) {
+ for (Tablet tablet : idx.getTablets()) {
+ // Cloud: each tablet has only one CloudReplica
(primary BE). The backend
+ // resolution depends on the current compute group
(ConnectContext); skip
+ // the tablet rather than aborting so other tablets
can still dispatch.
+ for (Replica replica : tablet.getReplicas()) {
+ long beId;
+ try {
Review Comment:
Catching every `UserException` here is too broad. `replica.getBackendId()`
throws `ComputeGroupException` for cases like missing `USAGE` privilege,
manually shut down compute groups, or missing compute groups, and this code
currently downgrades all of those into `skip tablet ...` plus the generic `no
tablet dispatched for compaction` message. That loses the real user-facing
failure and can also turn a hard error into a partial dispatch. If we want to
skip anything here, it should be only the specific transient no-BE cases; the
other exceptions need to be propagated unchanged.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AdminCompactTableCommand.java:
##########
@@ -51,7 +46,8 @@ public class AdminCompactTableCommand extends Command
implements ForwardWithSync
*/
public enum CompactionType {
CUMULATIVE,
- BASE
Review Comment:
Allowing `FULL` / cloud dispatch here without a BE capability gate is not
rolling-upgrade safe. On an older local BE,
`submit_table_compaction_callback()` still treats any non-`"base"` type as
cumulative compaction, so `type='FULL'` silently runs the wrong operation. On
an older cloud BE, `cloud_start_workers()` still has no `TTaskType::COMPACTION`
worker at all; BE returns `InvalidArgument`, but FE ignores `submit_tasks()`
status in `AgentBatchTask.run()`, so the SQL can return success while nothing
runs. We need a fail-fast FE-side version/capability check (or keep the old
cloud-mode gate) until all BEs are guaranteed upgraded.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]