Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry when store is down in high layer #2710

Merged
merged 8 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/alter-primary-key-false-test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: alter-primary-key-false-test

on:
push:
branches:
- master
pull_request:
branches:
- master
- release-3.1
- release-3.0
- release-2.5
- release-2.4

jobs:
test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.tikv.common.region.TiRegion;
import org.tikv.common.region.TiStore;
import org.tikv.common.region.TiStoreType;
import org.tikv.common.util.BackOffFunction;
import org.tikv.common.util.BackOffer;
import org.tikv.common.util.ConcreteBackOffer;
import org.tikv.common.util.RangeSplitter;
Expand Down Expand Up @@ -206,8 +207,9 @@ private SelectResponse process(RegionTask regionTask) {
Queue<SelectResponse> responseQueue = new ArrayDeque<>();
remainTasks.add(regionTask);
BackOffer backOffer = ConcreteBackOffer.newCopNextMaxBackOff();

HashSet<Long> resolvedLocks = new HashSet<>();
BackOffer storeUnreachableBackOffer = ConcreteBackOffer.newCustomBackOff(60 * 1000);

// In case of one region task spilt into several others, we ues a queue to properly handle all
// the remaining tasks.
while (!remainTasks.isEmpty()) {
Expand All @@ -220,6 +222,19 @@ private SelectResponse process(RegionTask regionTask) {
TiStore store = task.getStore();

try {
if (store == null || !store.isReachable()) {
storeUnreachableBackOffer.doBackOffWithMaxSleep(
BackOffFunction.BackOffFuncType.BoServerBusy,
2000,
new TiClientInternalException("retry timeout: store is null or unreachable"));
logger.warn("TiKV store is null or unreachable, invalid cache and retry");
clientSession.getTiKVSession().getRegionManager().invalidateRegion(region);
remainTasks.addAll(
RangeSplitter.newSplitter(clientSession.getTiKVSession().getRegionManager())
.splitRangeByRegion(ranges, storeType));
continue;
}

RegionStoreClient client =
clientSession
.getTiKVSession()
Expand Down