diff --git a/src/main/java/org/tikv/common/ConfigUtils.java b/src/main/java/org/tikv/common/ConfigUtils.java index e160bee9703..7d0223c5529 100644 --- a/src/main/java/org/tikv/common/ConfigUtils.java +++ b/src/main/java/org/tikv/common/ConfigUtils.java @@ -109,7 +109,7 @@ public class ConfigUtils { public static final int DEF_TIKV_RAWKV_SCAN_TIMEOUT_IN_MS = 10000; public static final int DEF_TIKV_RAWKV_CLEAN_TIMEOUT_IN_MS = 600000; - public static final int DEF_TIKV_BO_REGION_MISS_BASE_IN_MS = 100; + public static final int DEF_TIKV_BO_REGION_MISS_BASE_IN_MS = 20; public static final String NORMAL_COMMAND_PRIORITY = "NORMAL"; public static final String LOW_COMMAND_PRIORITY = "LOW"; diff --git a/src/main/java/org/tikv/common/region/AbstractRegionStoreClient.java b/src/main/java/org/tikv/common/region/AbstractRegionStoreClient.java index fcfd88cc50c..57551f1e2c8 100644 --- a/src/main/java/org/tikv/common/region/AbstractRegionStoreClient.java +++ b/src/main/java/org/tikv/common/region/AbstractRegionStoreClient.java @@ -126,8 +126,7 @@ public boolean onNotLeader(TiRegion newRegion) { @Override public boolean onStoreUnreachable() { if (!targetStore.isValid()) { - logger.warn( - String.format("store [%d] has been invalid", region.getId(), targetStore.getId())); + logger.warn(String.format("store [%d] has been invalid", targetStore.getId())); targetStore = regionManager.getStoreById(targetStore.getId()); updateClientStub(); return true; @@ -159,7 +158,7 @@ public boolean onStoreUnreachable() { } logger.warn( String.format( - "retry time exceed for region[%d], invalid this region[%d]", + "retry time exceed for region[%d], invalid store[%d]", region.getId(), targetStore.getId())); regionManager.onRequestFail(region); return false; @@ -194,11 +193,6 @@ public void tryUpdateRegionStore() { // create a new store object, which is can-forward. regionManager.updateStore(originStore, targetStore); } else { - // If we try to forward request to leader by follower failed, it means that the store of old - // leader may be - // unavailable but the new leader has not been report to PD. So we can ban this store for a - // short time to - // avoid too many request try forward rather than try other peer. originStore.forwardFail(); } } @@ -260,7 +254,18 @@ private void updateClientStub() { } private boolean retryOtherStoreByProxyForward() { - if (!conf.getEnableGrpcForward() || retryForwardTimes > region.getFollowerList().size()) { + if (!conf.getEnableGrpcForward()) { + return false; + } + if (retryForwardTimes >= region.getFollowerList().size()) { + // If we try to forward request to leader by follower failed, it means that the store of old + // leader may be + // unavailable but the new leader has not been report to PD. So we can ban this store for a + // short time to + // avoid too many request try forward rather than try other peer. + if (originStore != null) { + originStore.forwardFail(); + } return false; } TiStore proxyStore = switchProxyStore(); @@ -269,6 +274,11 @@ private boolean retryOtherStoreByProxyForward() { String.format( "no forward store can be selected for store [%s] and region[%d]", targetStore.getStore().getAddress(), region.getId())); + if (originStore != null) { + originStore.forwardFail(); + } else { + targetStore.forwardFail(); + } return false; } if (originStore == null) {