imbajin commented on code in PR #814:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/814#discussion_r4264257622


##########
hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/load/LoadTaskService.java:
##########
@@ -248,17 +253,40 @@ protected void executeAfterCommit(LoadTask task) {
                     public void afterCommit() {
                         executeSafely(task);
                     }
+
+                    @Override
+                    public void afterCompletion(int status) {
+                        if (status != 
TransactionSynchronization.STATUS_COMMITTED) {
+                            closeUnscheduled(task, null);
+                        }
+                    }
                 });
     }
 
     private void executeSafely(LoadTask task) {
         try {
             this.execute(task);
         } catch (RuntimeException e) {
+            closeUnscheduled(task, e);

Review Comment:
   Resume and retry now use the same guarded update/dispatch path as new tasks. 
Update failures, executor rejection, and dispatch Errors close the newly 
connected Loader and mark the unscheduled task failed while preserving the 
primary cause. Native Loader regression tests cover these paths; formatting, 
checkstyle, and the Client/Loader/Hubble backend unit reactor pass.



##########
hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/entity/load/LoadTask.java:
##########
@@ -177,18 +177,34 @@ public void run() {
         Ex.check(this.options != null, "The load options shouldn't be null");
         log.info("LoadTask is start running : {}", this.id);
 
-        boolean noError;
+        boolean noError = false;
+        boolean cleanupFailed = false;
+        Throwable failure = null;
         try {
             noError = this.loader.load();
         } catch (Throwable e) {
-            noError = false;
-            log.error("Run task {} failed", this.id, e);
+            failure = e;
+        } finally {
+            try {
+                this.loader.shutdown();
+            } catch (Throwable e) {
+                noError = false;
+                cleanupFailed = true;
+                if (failure == null) {
+                    failure = e;
+                } else if (failure != e) {
+                    failure.addSuppressed(e);
+                }
+            }
+        }
+        if (failure != null) {
+            log.error("Run task {} failed", this.id, failure);
         }
         this.lock.lock();
         try {
             // Pay attention to whether the user stops actively or
             // the program stops by itself
-            if (this.status.inRunning()) {
+            if (cleanupFailed || this.status.inRunning()) {

Review Comment:
   Cleanup now compares the recorded load failure with the native shutdown 
exception. A pure rethrow keeps PAUSED or STOPPED; an independent cleanup 
failure, including a new suppressed failure, marks the task FAILED and 
preserves the original cause. Native tests cover runtime, checked, Error, and 
UndeclaredThrowableException cases. A separate paired run with the 
Client/Loader owner changes also verifies successful release versus an 
independent HTTP release failure. Full shared-mode and Server integration 
remain separate validation gates.



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