diff --git a/tikv-client/src/main/java/com/pingcap/tikv/region/RegionManager.java b/tikv-client/src/main/java/com/pingcap/tikv/region/RegionManager.java index 32ffda2080..5888aed055 100644 --- a/tikv-client/src/main/java/com/pingcap/tikv/region/RegionManager.java +++ b/tikv-client/src/main/java/com/pingcap/tikv/region/RegionManager.java @@ -124,7 +124,8 @@ public Pair getRegionStorePairByKey( // select a tiflash with Round-Robin strategy if (tiflashStores.size() > 0) { store = - tiflashStores.get(Math.abs(tiflashStoreIndex.getAndIncrement() % tiflashStores.size())); + tiflashStores.get( + Math.floorMod(tiflashStoreIndex.getAndIncrement(), tiflashStores.size())); } if (store == null) {