This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b4f4b21da69 [fix](catalog) fix wrong issue of getBackendMeta (#59191)
b4f4b21da69 is described below
commit b4f4b21da6998548fb41f1df7d518718e7b598ba
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Mon Dec 22 10:24:38 2025 +0800
[fix](catalog) fix wrong issue of getBackendMeta (#59191)
### What problem does this PR solve?
Related PR: #57898
Problem Summary:
The `getBackendMeta` does not need to call to Master FE.
If use specified non-master FE address in Doris Catalog, it will result
in dead loop
---
.../doris/datasource/doris/FeServiceClient.java | 68 +---------------------
.../apache/doris/service/FrontendServiceImpl.java | 6 +-
2 files changed, 3 insertions(+), 71 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/doris/FeServiceClient.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/doris/FeServiceClient.java
index 56e28f605c6..d5b21a872e7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/doris/FeServiceClient.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/doris/FeServiceClient.java
@@ -53,7 +53,6 @@ public class FeServiceClient {
private final Random random = new Random(System.currentTimeMillis());
private final String name;
private final List<TNetworkAddress> addresses;
- private volatile TNetworkAddress master;
private final String user;
private final String password;
private final int retryCount;
@@ -118,79 +117,16 @@ public class FeServiceClient {
throw new RuntimeException(errorMsg + ":" +
lastException.getMessage(), lastException);
}
- private <T> T callFromMaster(ThriftCall<MasterResult<T>> call, String
errorMsg, int timeout) {
- TNetworkAddress address = master;
- FrontendService.Client client = null;
- Exception lastException = null;
- if (address != null) {
- client = getRemoteFeClient(address, timeout);
- boolean returnObj = false;
- try {
- MasterResult<T> ret = call.call(client);
- returnObj = true;
- if (ret.isMaster) {
- if (ret.hasError) {
- throw new RuntimeException(ret.errorMsg);
- }
- return ret.result;
- }
- } catch (TException | IOException e) {
- lastException = e;
- } catch (Exception e) {
- throw new RuntimeException(errorMsg + ":" + e.getMessage(), e);
- } finally {
- returnClient(address, client, returnObj);
- }
- }
- master = null;
- List<TNetworkAddress> addresses = getAddresses();
- int retries = 0;
- while (retries < retryCount) {
- int index = random.nextInt(addresses.size());
- for (int i = 0; i < addresses.size() && retries < retryCount; i++)
{
- address = addresses.get((index + i) % addresses.size());
- client = getRemoteFeClient(address, timeout);
- boolean returnObj = false;
- try {
- MasterResult<T> ret = call.call(client);
- returnObj = true;
- if (ret.isMaster) {
- master = address;
- if (ret.hasError) {
- throw new RuntimeException(ret.errorMsg);
- }
- return ret.result;
- }
- } catch (TException | IOException e) {
- lastException = e;
- retries++;
- } catch (Exception e) {
- throw new RuntimeException(errorMsg + ":" +
e.getMessage(), e);
- } finally {
- returnClient(address, client, returnObj);
- }
- }
- }
- throw new RuntimeException(errorMsg + ":" +
lastException.getMessage(), lastException);
- }
-
public List<Backend> listBackends() {
TGetBackendMetaRequest request = new TGetBackendMetaRequest();
request.setUser(user);
request.setPasswd(password);
String msg = String.format("failed to get backends from remote
doris:%s", name);
- return callFromMaster(client -> {
+ return randomCallWithRetry(client -> {
TGetBackendMetaResult result = client.getBackendMeta(request);
- if (result.getStatus().getStatusCode() == TStatusCode.NOT_MASTER) {
- return MasterResult.notMaster();
- }
- if (result.getStatus().getStatusCode() != TStatusCode.OK) {
- return
MasterResult.masterWithError(result.getStatus().toString());
- }
- List<Backend> backends = result.getBackends().stream()
+ return result.getBackends().stream()
.map(b -> Backend.fromThrift(b))
.collect(Collectors.toList());
- return MasterResult.withResult(backends);
}, msg, timeout);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 4e586a91ede..972c09a757d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -4179,13 +4179,9 @@ public class FrontendServiceImpl implements
FrontendService.Iface {
}
TGetBackendMetaResult result = new TGetBackendMetaResult();
- TStatus status = checkMaster();
+ TStatus status = new TStatus(TStatusCode.OK);
result.setStatus(status);
- if (status.getStatusCode() != TStatusCode.OK) {
- return result;
- }
-
try {
result = getBackendMetaImpl(request, clientAddr);
} catch (UserException e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]