From c43d0e2a759aa4d53fdb3bf451a02db92ffebc51 Mon Sep 17 00:00:00 2001 From: Mingyu Chen Date: Thu, 26 Dec 2019 15:31:36 +0800 Subject: [PATCH] [Tablet report] Fix bug that tablet report throw NPE. (#2578) When processing tablet reports, some tablets carry transaction information. This information is used by the FE to determine whether to publish these transactions or clear these transactions. During this process, Doris may try to obtain the commit information of some deleted partitions, resulting in a null pointer exception. --- .../doris/catalog/TabletInvertedIndex.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/fe/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java b/fe/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java index 798411bb6e..b2d00cf9f1 100644 --- a/fe/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java +++ b/fe/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java @@ -196,18 +196,28 @@ public class TabletInvertedIndex { TableCommitInfo tableCommitInfo = transactionState.getTableCommitInfo(tabletMeta.getTableId()); PartitionCommitInfo partitionCommitInfo = tableCommitInfo.getPartitionCommitInfo(partitionId); if (partitionCommitInfo == null) { - LOG.warn("failed to find partition commit info. table: {}, partition: {}, tablet: {}, txn id: {}", + /* + * This may happen as follows: + * 1. txn is committed on BE, and report commit info to FE + * 2. FE received report and begin to assemble partitionCommitInfos. + * 3. At the same time, some of partitions have been dropped, so partitionCommitInfos does not contain these partitions. + * 4. So we will not able to get partitionCommitInfo here. + * + * Just print a log to observe + */ + LOG.info("failed to find partition commit info. table: {}, partition: {}, tablet: {}, txn id: {}", tabletMeta.getTableId(), partitionId, tabletId, transactionState.getTransactionId()); + } else { + TPartitionVersionInfo versionInfo = new TPartitionVersionInfo(tabletMeta.getPartitionId(), + partitionCommitInfo.getVersion(), + partitionCommitInfo.getVersionHash()); + ListMultimap map = transactionsToPublish.get(transactionState.getDbId()); + if (map == null) { + map = ArrayListMultimap.create(); + transactionsToPublish.put(transactionState.getDbId(), map); + } + map.put(transactionId, versionInfo); } - TPartitionVersionInfo versionInfo = new TPartitionVersionInfo(tabletMeta.getPartitionId(), - partitionCommitInfo.getVersion(), - partitionCommitInfo.getVersionHash()); - ListMultimap map = transactionsToPublish.get(transactionState.getDbId()); - if (map == null) { - map = ArrayListMultimap.create(); - transactionsToPublish.put(transactionState.getDbId(), map); - } - map.put(transactionId, versionInfo); } } } // end for txn id