baiyangtx commented on code in PR #2720:
URL: https://github.com/apache/amoro/pull/2720#discussion_r1559036792


##########
ams/server/src/main/java/com/netease/arctic/server/optimizing/OptimizingQueue.java:
##########
@@ -544,27 +544,32 @@ public void commit() {
           taskMap.size(),
           taskMap.values());
 
+      boolean needCleanupTasks = false;
       lock.lock();
       try {
         if (hasCommitted) {
           LOG.warn("{} has already committed, give up", 
tableRuntime.getTableIdentifier());
           throw new IllegalStateException("repeat commit, and last error " + 
failedReason);
         }
-        hasCommitted = true;
-        buildCommit().commit();
-        status = Status.SUCCESS;
-        endTime = System.currentTimeMillis();
-        persistProcessCompleted(true);
-      } catch (Exception e) {
-        LOG.error("{} Commit optimizing failed ", 
tableRuntime.getTableIdentifier(), e);
-        status = Status.FAILED;
-        failedReason = ExceptionUtil.getErrorMessage(e, 4000);
-        endTime = System.currentTimeMillis();
-        persistProcessCompleted(false);
+        try {
+          hasCommitted = true;
+          buildCommit().commit();
+          status = Status.SUCCESS;
+          endTime = System.currentTimeMillis();
+          persistProcessCompleted(true);
+        } catch (Exception e) {
+          LOG.error("{} Commit optimizing failed ", 
tableRuntime.getTableIdentifier(), e);
+          status = Status.FAILED;
+          needCleanupTasks = true;
+          failedReason = ExceptionUtil.getErrorMessage(e, 4000);
+          endTime = System.currentTimeMillis();
+          persistProcessCompleted(false);
+        } finally {
+          clearProcess(this);
+        }
       } finally {
-        clearProcess(this);
         lock.unlock();
-        if (this.status == OptimizingProcess.Status.FAILED) {
+        if (needCleanupTasks) {

Review Comment:
   fixed



-- 
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]

Reply via email to