[BugFix](TabletInvertedIndex) fix replica not found in TabletInvertedIndex (#34117)

* fix replica not found in TabletInvertedIndex
This commit is contained in:
GoGoWen
2024-04-29 10:45:28 +08:00
committed by yiguolei
parent fe7d2b8159
commit 74029f56d4

View File

@ -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 {}",