imbajin commented on code in PR #704:
URL: 
https://github.com/apache/incubator-hugegraph-toolchain/pull/704#discussion_r2704452947


##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/task/TaskManager.java:
##########
@@ -152,10 +156,17 @@ public void submitBatch(InputStruct struct, 
ElementMapping mapping,
         CompletableFuture.runAsync(task, this.batchService).whenComplete(
             (r, e) -> {
                 if (e != null) {
-                    LOG.warn("Batch insert {} error, try single insert",
-                             mapping.type(), e);
-                    // The time of single insert is counted separately
-                    this.submitInSingle(struct, mapping, batch);
+                    LOG.error("Batch insert {} error, interrupting import", 
mapping.type(), e);

Review Comment:
   ‼️ **Critical - 批量失败后资源未正确释放**
   
   当批量插入失败且 `batchFailureFallback=false` 时,代码会调用 `stopLoading()` 并返回,但 **没有调用 
`minusFlighting(batch.size())`** 来减少飞行中的记录计数器。这会导致:
   1. 计数器永久不平衡
   2. 可能导致内存泄漏或统计不准确
   3. 信号量已释放但计数未调整
   
   **建议修复:**
   ```suggestion
                       LOG.error("Batch insert {} error, interrupting import", 
mapping.type(), e);
                       summary.metrics(struct).minusFlighting(batch.size());
                       if (this.options.batchFailureFallback) {
                           LOG.warn("Batch insert {} error, try single insert",
                                    mapping.type(), e);
                           this.submitInSingle(struct, mapping, batch);
                       } else {
                           this.context.occurredError();
                           this.context.stopLoading();
                           Printer.printError("Batch insert %s failed, stop 
loading. Please check the logs",
                                              mapping.type().string());
                       }
   ```
   
   **需要测试:**
   1. 模拟批量插入失败场景,验证 `summary.metrics(struct).flighting` 计数器是否正确归零
   2. 确认多次失败后计数器不会累积错误



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