Skip to content

Commit

Permalink
[AMORO-1242] Fix refreshing a large number of tables during optimizin…
Browse files Browse the repository at this point in the history
…g plan (apache#1928)

* checking pending before refresh table

* add log for plan cost if table is pending
  • Loading branch information
wangtaohz authored Sep 7, 2023
1 parent b9257c1 commit f721b9a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,10 @@ private List<OptimizeTaskItem> plan(long currentTime) {
for (TableIdentifier tableIdentifier : tableSort) {
try {
TableOptimizeItem tableItem = ServiceContainer.getOptimizeService().getTableOptimizeItem(tableIdentifier);
if (tableItem.getTableOptimizeRuntime().getOptimizeStatus() != TableOptimizeRuntime.OptimizeStatus.Pending) {
// only table in pending should plan
continue;
}
ArcticTable arcticTable = tableItem.getArcticTable(true);

Map<String, String> properties = arcticTable.properties();
Expand Down Expand Up @@ -764,12 +768,8 @@ private List<OptimizeTaskItem> plan(long currentTime) {
}
}

if (tableItem.getTableOptimizeRuntime().getOptimizeStatus() != TableOptimizeRuntime.OptimizeStatus.Pending) {
// only table in pending should plan
continue;
}

OptimizePlanResult optimizePlanResult = OptimizePlanResult.EMPTY;
long startPlanTime = System.currentTimeMillis();
if (tableItem.startPlanIfNot()) {
try {
if (TableTypeUtil.isIcebergTableFormat(arcticTable)) {
Expand All @@ -779,13 +779,13 @@ private List<OptimizeTaskItem> plan(long currentTime) {
}
} finally {
tableItem.finishPlan();
LOG.info("{} finish plan cost {} ms, get {} tasks", tableItem.getTableIdentifier(),
System.currentTimeMillis() - startPlanTime, optimizePlanResult.getOptimizeTasks().size());
}
}

if (!optimizePlanResult.isEmpty()) {
initTableOptimizeRuntime(tableItem, optimizePlanResult);
LOG.debug("{} after plan get {} tasks", tableItem.getTableIdentifier(),
optimizePlanResult.getOptimizeTasks().size());

List<OptimizeTaskItem> toExecuteTasks = addTask(tableItem, optimizePlanResult.getOptimizeTasks());
if (!toExecuteTasks.isEmpty()) {
Expand Down

0 comments on commit f721b9a

Please sign in to comment.