deardeng commented on code in PR #28079:
URL: https://github.com/apache/doris/pull/28079#discussion_r1427673698


##########
fe/fe-core/src/main/java/org/apache/doris/transaction/PublishVersionDaemon.java:
##########
@@ -132,27 +133,45 @@ private void publishVersion() {
         Map<Long, Long> tableIdToTotalDeltaNumRows = Maps.newHashMap();
         // try to finish the transaction, if failed just retry in next loop
         for (TransactionState transactionState : readyTransactionStates) {
-            Stream<PublishVersionTask> publishVersionTaskStream = 
transactionState
-                    .getPublishVersionTasks()
-                    .values()
-                    .stream()
-                    .peek(task -> {
-                        if (task.isFinished() && 
CollectionUtils.isEmpty(task.getErrorTablets())) {
-                            Map<Long, Long> tableIdToDeltaNumRows =
-                                    task.getTableIdToDeltaNumRows();
-                            tableIdToDeltaNumRows.forEach((tableId, numRows) 
-> {
-                                tableIdToTotalDeltaNumRows
-                                        .computeIfPresent(tableId, (id, 
orgNumRows) -> orgNumRows + numRows);
-                                
tableIdToTotalDeltaNumRows.putIfAbsent(tableId, numRows);
-                            });
-                        }
-                    });
-            boolean hasBackendAliveAndUnfinishedTask = publishVersionTaskStream
-                    .anyMatch(task -> !task.isFinished() && 
infoService.checkBackendAlive(task.getBackendId()));
+            AtomicReference<Long> finishNum = new AtomicReference<>(0L);
+            AtomicBoolean hasBackendAliveAndUnfinishedTask = new 
AtomicBoolean(false);
+            Set<Long> notFinishTaskBe = Sets.newHashSet();
+            transactionState.getPublishVersionTasks().forEach((beId, task) -> {
+                if (task.isFinished()) {
+                    finishNum.set(finishNum.get() + 1);
+                    if (CollectionUtils.isEmpty(task.getErrorTablets())) {
+                        Map<Long, Long> tableIdToDeltaNumRows = 
task.getTableIdToDeltaNumRows();
+                        tableIdToDeltaNumRows.forEach((tableId, numRows) -> {
+                            tableIdToTotalDeltaNumRows
+                                .computeIfPresent(tableId, (id, orgNumRows) -> 
orgNumRows + numRows);
+                            tableIdToTotalDeltaNumRows.putIfAbsent(tableId, 
numRows);
+                        });
+                    }
+                } else {
+                    if (infoService.checkBackendAlive(task.getBackendId())) {
+                        hasBackendAliveAndUnfinishedTask.set(true);
+                    }
+                    notFinishTaskBe.add(beId);
+                }
+            });
+
             
transactionState.setTableIdToTotalNumDeltaRows(tableIdToTotalDeltaNumRows);
+            LOG.debug("notFinishTaskBe {}, trans {}", notFinishTaskBe, 
transactionState);
+            boolean isPublishSlow = false;
+            if (finishNum.get() > 
transactionState.getPublishVersionTasks().keySet().size() / 2
+                    && notFinishTaskBe.stream()
+                        .allMatch(beId -> 
infoService.getBackend(beId).getPublishTaskLastTimeAccumulated())) {
+                LOG.debug(" finishNum {}, txn publish tasks {}, 
notFinishTaskBe {}",
+                        finishNum, 
transactionState.getPublishVersionTasks().keySet(), notFinishTaskBe);
+                isPublishSlow = true;
+            }
 
-            boolean shouldFinishTxn = !hasBackendAliveAndUnfinishedTask || 
transactionState.isPublishTimeout()
+            boolean shouldFinishTxn = !hasBackendAliveAndUnfinishedTask.get() 
|| transactionState.isPublishTimeout()
+                    || isPublishSlow
                     || 
DebugPointUtil.isEnable("PublishVersionDaemon.not_wait_unfinished_tasks");
+            LOG.debug("hasBackendAliveAndUnfinishedTask {}, txn 
isPublishTimeout {}, DebugPoint enable {}, slow {}",

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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to