Skip to content

Commit

Permalink
branch-2.1: [Improve](Variant) pick random backend as coordinator #45754
Browse files Browse the repository at this point in the history
 (#45771)

Cherry-picked from #45754

Co-authored-by: lihangyu <[email protected]>
  • Loading branch information
github-actions[bot] and eldenmoon authored Dec 23, 2024
1 parent d70c17b commit 3006eea
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 3006eea

Please sign in to comment.