diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java index 952d349714ba04..81c5a3bfdba81c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java @@ -470,8 +470,8 @@ private void commitTransaction(long dbId, List tableList, long transactio "disable_load_job is set to true, all load jobs are not allowed"); } - List mowTableList = getMowTableList(tableList); - if (tabletCommitInfos != null && !tabletCommitInfos.isEmpty() && !mowTableList.isEmpty()) { + List mowTableList = getMowTableList(tableList, tabletCommitInfos); + if (!mowTableList.isEmpty()) { calcDeleteBitmapForMow(dbId, mowTableList, transactionId, tabletCommitInfos); } @@ -482,12 +482,8 @@ private void commitTransaction(long dbId, List
tableList, long transactio .setCloudUniqueId(Config.cloud_unique_id) .addAllBaseTabletIds(getBaseTabletsFromTables(tableList, tabletCommitInfos)) .setEnableTxnLazyCommit(Config.enable_cloud_txn_lazy_commit); - - // if tablet commit info is empty, no need to pass mowTableList to meta service. - if (tabletCommitInfos != null && !tabletCommitInfos.isEmpty()) { - for (OlapTable olapTable : mowTableList) { - builder.addMowTableIds(olapTable.getId()); - } + for (OlapTable olapTable : mowTableList) { + builder.addMowTableIds(olapTable.getId()); } if (txnCommitAttachment != null) { @@ -601,14 +597,27 @@ private TransactionState commitTxn(CommitTxnRequest commitTxnRequest, long trans return txnState; } - private List getMowTableList(List
tableList) { + // return mow tables with contains tablet commit info + private List getMowTableList(List
tableList, List tabletCommitInfos) { + if (tabletCommitInfos == null || tabletCommitInfos.isEmpty()) { + return Lists.newArrayList(); + } List mowTableList = new ArrayList<>(); + TabletInvertedIndex tabletInvertedIndex = Env.getCurrentEnv().getTabletInvertedIndex(); for (Table table : tableList) { - if ((table instanceof OlapTable)) { - OlapTable olapTable = (OlapTable) table; - if (olapTable.getEnableUniqueKeyMergeOnWrite()) { - mowTableList.add(olapTable); - } + if (!(table instanceof OlapTable)) { + continue; + } + OlapTable olapTable = (OlapTable) table; + if (!olapTable.getEnableUniqueKeyMergeOnWrite()) { + continue; + } + boolean hasTabletCommitInfo = tabletCommitInfos.stream().anyMatch(ci -> { + TabletMeta tabletMeta = tabletInvertedIndex.getTabletMeta(ci.getTabletId()); + return tabletMeta != null && tabletMeta.getTableId() == olapTable.getId(); + }); + if (hasTabletCommitInfo) { + mowTableList.add(olapTable); } } return mowTableList;