Skip to content

Commit

Permalink
[Improve](Variant) pick random backend as coordinator (#45754)
Browse files Browse the repository at this point in the history
pick random rpc coordinator to do fetch_remote_tablet_schema service
  • Loading branch information
eldenmoon authored and Your Name committed Dec 23, 2024
1 parent b845813 commit b998742
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,19 @@ 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);
if (!coordinatorBackend.isEmpty()) {
coordinatorBackend = coordinatorBackend.subList(0, Math.min(2, coordinatorBackend.size()));
LOG.debug("pick coordinator backend {}", coordinatorBackend.get(0));
}
PFetchRemoteSchemaRequest.Builder requestBuilder = PFetchRemoteSchemaRequest.newBuilder()
.addAllTabletLocation(locations)
.setIsCoordinator(true);
Expand Down

0 comments on commit b998742

Please sign in to comment.