[fix](clone) fix check replica failed due to replica had drop #35994 (#36219)

cherry pick from #35994
This commit is contained in:
yujun
2024-06-13 13:39:09 +08:00
committed by GitHub
parent 106a55497b
commit e51cd58d6e
2 changed files with 20 additions and 4 deletions

View File

@ -213,7 +213,12 @@ public class BeLoadRebalancer extends Rebalancer {
continue;
}
Replica replica = invertedIndex.getReplica(tabletId, beStat.getBeId());
Replica replica = null;
try {
replica = invertedIndex.getReplica(tabletId, beStat.getBeId());
} catch (IllegalStateException e) {
continue;
}
if (replica == null) {
continue;
}
@ -222,6 +227,7 @@ public class BeLoadRebalancer extends Rebalancer {
// and only select it if the selected tablets num of this path
// does not exceed the limit (BALANCE_SLOT_NUM_FOR_PATH).
long replicaPathHash = replica.getPathHash();
long replicaDataSize = replica.getDataSize();
if (remainingPaths.containsKey(replicaPathHash)) {
TabletMeta tabletMeta = invertedIndex.getTabletMeta(tabletId);
if (tabletMeta == null) {
@ -244,7 +250,7 @@ public class BeLoadRebalancer extends Rebalancer {
continue;
}
boolean isFit = lowBEs.stream().anyMatch(be -> be.isFit(replica.getDataSize(),
boolean isFit = lowBEs.stream().anyMatch(be -> be.isFit(replicaDataSize,
medium, null, false) == BalanceStatus.OK);
if (!isFit) {
if (LOG.isDebugEnabled()) {

View File

@ -217,7 +217,12 @@ public class DiskRebalancer extends Rebalancer {
&& invertedIndex.getReplicasByTabletId(tabletId).size() <= 1) {
continue;
}
Replica replica = invertedIndex.getReplica(tabletId, beStat.getBeId());
Replica replica = null;
try {
replica = invertedIndex.getReplica(tabletId, beStat.getBeId());
} catch (IllegalStateException e) {
continue;
}
if (replica == null) {
continue;
}
@ -304,7 +309,12 @@ public class DiskRebalancer extends Rebalancer {
throw new SchedException(Status.UNRECOVERABLE,
"src does not appear to be set correctly, something goes wrong");
}
Replica replica = invertedIndex.getReplica(tabletCtx.getTabletId(), tabletCtx.getTempSrcBackendId());
Replica replica = null;
try {
replica = invertedIndex.getReplica(tabletCtx.getTabletId(), tabletCtx.getTempSrcBackendId());
} catch (IllegalStateException e) {
replica = null;
}
// check src replica still there
if (replica == null || replica.getPathHash() != tabletCtx.getTempSrcPathHash()) {
throw new SchedException(Status.UNRECOVERABLE, SubCode.DIAGNOSE_IGNORE, "src replica may be rebalanced");