zhoujinsong commented on code in PR #2720:
URL: https://github.com/apache/incubator-amoro/pull/2720#discussion_r1555352982
##########
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:
I don't think we need to cancel all tasks here even if the commit failed. If
the process reaches the commit stage, all tasks should have been completed by
then. The task status should only be in the `SUCCESS` status at this point and
will not enter the `CANCEL` status again.
--
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]