chihsuan commented on code in PR #11585:
URL: https://github.com/apache/ozone/pull/11585#discussion_r4325344454


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconScmTask.java:
##########
@@ -92,10 +93,20 @@ public ReconTaskStatusUpdater getTaskStatusUpdater() {
 
   protected abstract void run();
 
-  protected void initializeAndRunTask() throws Exception {
+  protected void initializeAndRunTask() throws InterruptedException {
     taskStatusUpdater.recordRunStart();
-    runTask();
-    taskStatusUpdater.recordRunCompletion();
+    try {
+      taskStatusUpdater.setLastTaskRunStatus(0);
+      runTask();
+    } catch (InterruptedException e) {
+      taskStatusUpdater.setLastTaskRunStatus(-1);
+      throw e;
+    } catch (Exception e) {
+      LOG.error("Failed to run task {}.", getTaskName(), e);
+      taskStatusUpdater.setLastTaskRunStatus(-1);

Review Comment:
   Should we also mark the run as failed when `runTask()` throws an `Error`? 
The status is set to `0` up front, so an `Error` skips both catches and 
`finally` saves a successful run as the thread exits.
   
   ```suggestion
       } catch (Exception e) {
         LOG.error("Failed to run task {}.", getTaskName(), e);
         taskStatusUpdater.setLastTaskRunStatus(-1);
       } catch (Error e) {
         LOG.error("Task {} failed with an unrecoverable error.", 
getTaskName(), e);
         taskStatusUpdater.setLastTaskRunStatus(-1);
         throw e;
   ```



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

Reply via email to