Skip to content

Commit

Permalink
[Improve](Variant) pick random backend as coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Dec 21, 2024
1 parent cf6dba7 commit 93585ac
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ public List<Column> fetch() {
if (!backend.isAlive()) {
continue;
}
// need 2 be to provide a retry
if (coordinatorBackend.size() < 2) {
coordinatorBackend.add(backend);
}
coordinatorBackend.add(backend);
PTabletsLocation.Builder locationBuilder = PTabletsLocation.newBuilder()
.setHost(backend.getHost())
.setBrpcPort(backend.getBrpcPort());
PTabletsLocation location = locationBuilder.addAllTabletId(tabletIds).build();
locations.add(location);
}
// pick 2 random coordinator
Collections.shuffle(coordinatorBackend);
coordinatorBackend = coordinatorBackend.subList(0, 2);
PFetchRemoteSchemaRequest.Builder requestBuilder = PFetchRemoteSchemaRequest.newBuilder()
.addAllTabletLocation(locations)
.setIsCoordinator(true);
Expand Down

0 comments on commit 93585ac

Please sign in to comment.