This is an automated email from the ASF dual-hosted git repository.

caiconghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 5514b1c1b7 [enhancement](tablet_report) accelerate deleteFromBackend 
function to avoid tablet report task blocked (#16115)
5514b1c1b7 is described below

commit 5514b1c1b74fbf442a4d36e25504f6bcb0e1fc30
Author: caiconghui <55968745+caicong...@users.noreply.github.com>
AuthorDate: Fri Jan 20 20:11:58 2023 +0800

    [enhancement](tablet_report) accelerate deleteFromBackend function to avoid 
tablet report task blocked (#16115)
---
 .../org/apache/doris/master/ReportHandler.java     | 33 +++++++++++-----------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java
index 055fd59594..f3090fa212 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java
@@ -683,21 +683,27 @@ public class ReportHandler extends Daemon {
         int deleteFromBackendCounter = 0;
         int addToMetaCounter = 0;
         AgentBatchTask batchTask = new AgentBatchTask();
+        TabletInvertedIndex invertedIndex = Env.getCurrentInvertedIndex();
         for (Long tabletId : backendTablets.keySet()) {
             TTablet backendTablet = backendTablets.get(tabletId);
             TTabletInfo backendTabletInfo = 
backendTablet.getTabletInfos().get(0);
             boolean needDelete = false;
+            TabletMeta tabletMeta = null;
             if (!tabletFoundInMeta.contains(tabletId)) {
                 if (isBackendReplicaHealthy(backendTabletInfo)) {
-                    // if this tablet is not in meta. try adding it.
+                    // if this tablet meta is still in invertedIndex. try to 
add it.
                     // if add failed. delete this tablet from backend.
                     try {
-                        addReplica(tabletId, backendTabletInfo, backendId);
-                        // update counter
-                        needDelete = false;
-                        ++addToMetaCounter;
+                        tabletMeta = invertedIndex.getTabletMeta(tabletId);
+                        if (tabletMeta != null) {
+                            addReplica(tabletId, tabletMeta, 
backendTabletInfo, backendId);
+                            // update counter
+                            ++addToMetaCounter;
+                        } else {
+                            needDelete = true;
+                        }
                     } catch (MetaNotFoundException e) {
-                        LOG.warn("failed add to meta. tablet[{}], backend[{}]. 
{}",
+                        LOG.debug("failed add to meta. tablet[{}], 
backend[{}]. {}",
                                 tabletId, backendId, e.getMessage());
                         needDelete = true;
                     }
@@ -709,11 +715,11 @@ public class ReportHandler extends Daemon {
             if (needDelete) {
                 // drop replica
                 long replicaId = backendTabletInfo.getReplicaId();
-                boolean isDropTableOrPartition = 
Env.getCurrentInvertedIndex().getTabletMeta(tabletId) == null;
+                boolean isDropTableOrPartition = tabletMeta == null;
                 DropReplicaTask task = new DropReplicaTask(backendId, 
tabletId, replicaId,
                         backendTabletInfo.getSchemaHash(), 
isDropTableOrPartition);
                 batchTask.addTask(task);
-                LOG.warn("delete tablet[" + tabletId + "] from backend[" + 
backendId + "] because not found in meta");
+                LOG.debug("delete tablet[{}] from backend[{}] because not 
found in meta", tabletId, backendId);
                 ++deleteFromBackendCounter;
             }
         } // end for backendTabletIds
@@ -891,16 +897,8 @@ public class ReportHandler extends Daemon {
         AgentTaskExecutor.submit(batchTask);
     }
 
-    private static void addReplica(long tabletId, TTabletInfo 
backendTabletInfo, long backendId)
+    private static void addReplica(long tabletId, TabletMeta tabletMeta, 
TTabletInfo backendTabletInfo, long backendId)
             throws MetaNotFoundException {
-        TabletInvertedIndex invertedIndex = Env.getCurrentInvertedIndex();
-        SystemInfoService infoService = Env.getCurrentSystemInfo();
-
-        TabletMeta tabletMeta = invertedIndex.getTabletMeta(tabletId);
-        if (tabletMeta == null || tabletMeta == 
TabletInvertedIndex.NOT_EXIST_TABLET_META) {
-            throw new MetaNotFoundException("tablet meta[" + tabletMeta + "] 
does not exist in tablet inverted index");
-        }
-
         long dbId = tabletMeta.getDbId();
         long tableId = tabletMeta.getTableId();
         long partitionId = tabletMeta.getPartitionId();
@@ -952,6 +950,7 @@ public class ReportHandler extends Daemon {
                 return;
             }
 
+            SystemInfoService infoService = Env.getCurrentSystemInfo();
             List<Long> aliveBeIdsInCluster = 
infoService.getClusterBackendIds(db.getClusterName(), true);
             Pair<TabletStatus, TabletSchedCtx.Priority> status = 
tablet.getHealthStatusWithPriority(infoService,
                     db.getClusterName(), visibleVersion,


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

Reply via email to