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


##########
fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java:
##########
@@ -559,8 +567,16 @@ private static void taskReport(long backendId, 
Map<TTaskType, Set<Long>> running
         if (batchTask.getTaskNum() > 0) {
             AgentTaskExecutor.submit(batchTask);
         }
-        LOG.info("finished to handle task report from backend {}, diff task 
num: {}. cost: {} ms",
-                backendId, batchTask.getTaskNum(), (System.currentTimeMillis() 
- start));
+
+        int publishTaskSize = runningTasks.get(TTaskType.PUBLISH_VERSION) != 
null
+                ? runningTasks.get(TTaskType.PUBLISH_VERSION).size() : 0;
+        LOG.info("finished to handle task report from backend {}-{}, "
+                + "diff task num: {}, runningTasks: {}, publishSize: {}, cost: 
{} ms.",

Review Comment:
   fixed



##########
fe/fe-core/src/main/java/org/apache/doris/transaction/PublishVersionDaemon.java:
##########
@@ -151,26 +151,43 @@ 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()));
+            AtomicBoolean hasBackendAliveAndUnfinishedTask = new 
AtomicBoolean(false);
+            Set<Long> notFinishTaskBe = Sets.newHashSet();
+            transactionState.getPublishVersionTasks().forEach((beId, task) -> {
+                if (task.isFinished()) {
+                    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;
+            long totalNum = 
transactionState.getPublishVersionTasks().keySet().size();
+            boolean allUnFinishTaskIsSlow = 
notFinishTaskBe.stream().allMatch(beId -> infoService.getBackend(beId)
+                    .getPublishTaskLastTimeAccumulated() > 
Config.publish_version_queued_limit_number);
+            if (totalNum - notFinishTaskBe.size() > totalNum / 2 && 
allUnFinishTaskIsSlow) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug(" finishNum {}, txn publish tasks {}, 
notFinishTaskBe {}",
+                            totalNum - notFinishTaskBe.size(), 
transactionState.getPublishVersionTasks().keySet(),
+                            notFinishTaskBe);
+                }
+                isPublishSlow = true;
+            }
 
-            boolean shouldFinishTxn = !hasBackendAliveAndUnfinishedTask || 
transactionState.isPublishTimeout()
+            boolean shouldFinishTxn = !hasBackendAliveAndUnfinishedTask.get() 
|| transactionState.isPublishTimeout()
+                    || isPublishSlow

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