From b9987423bd718635e0849f46991cac00dbd229b5 Mon Sep 17 00:00:00 2001 From: lihangyu Date: Mon, 23 Dec 2024 10:38:14 +0800 Subject: [PATCH] [Improve](Variant) pick random backend as coordinator (#45754) pick random rpc coordinator to do fetch_remote_tablet_schema service --- .../common/util/FetchRemoteTabletSchemaUtil.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/FetchRemoteTabletSchemaUtil.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/FetchRemoteTabletSchemaUtil.java index 0e96dc8c5930d1..de378c8b8e8a14 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/FetchRemoteTabletSchemaUtil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/FetchRemoteTabletSchemaUtil.java @@ -98,16 +98,19 @@ public List 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);