This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 74029f56d48b56796ab66695a55480835645405c Author: GoGoWen <[email protected]> AuthorDate: Mon Apr 29 10:45:28 2024 +0800 [BugFix](TabletInvertedIndex) fix replica not found in TabletInvertedIndex (#34117) * fix replica not found in TabletInvertedIndex --- .../org/apache/doris/catalog/TabletInvertedIndex.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java index c4650cb5e05..5fd7ae721f2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TabletInvertedIndex.java @@ -617,8 +617,19 @@ public class TabletInvertedIndex { "tablet " + tabletId + " not exists, backend " + backendId); if (replicaMetaTable.containsRow(tabletId)) { Replica replica = replicaMetaTable.remove(tabletId, backendId); - replicaToTabletMap.remove(replica.getId()); - replicaMetaTable.remove(tabletId, backendId); + + // sometimes, replicas may have same replica id in different backend + // we need to cover this situation to avoid some "replica not found" issue + if (replicaMetaTable.containsRow(tabletId)) { + long replicaNum = replicaMetaTable.row(tabletId).values().stream() + .filter(c -> c.getId() == replica.getId()).count(); + if (replicaNum == 0) { + replicaToTabletMap.remove(replica.getId()); + } + } else { + replicaToTabletMap.remove(replica.getId()); + } + backingReplicaMetaTable.remove(backendId, tabletId); if (LOG.isDebugEnabled()) { LOG.debug("delete replica {} of tablet {} in backend {}", --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
