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 65fc162279b5d9..b4029242975828 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 @@ -2797,6 +2797,15 @@ public TGetBinlogResult getBinlog(TGetBinlogRequest request) throws TException { TGetBinlogResult result = new TGetBinlogResult(); TStatus status = new TStatus(TStatusCode.OK); result.setStatus(status); + + if (!Env.getCurrentEnv().isMaster()) { + status.setStatusCode(TStatusCode.NOT_MASTER); + status.addToErrorMsgs(NOT_MASTER_ERR_MSG); + result.setMasterAddress(getMasterAddress()); + LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG); + return result; + } + try { result = getBinlogImpl(request, clientAddr); } catch (UserException e) { @@ -3138,6 +3147,14 @@ public TGetBinlogLagResult getBinlogLag(TGetBinlogRequest request) throws TExcep TStatus status = new TStatus(TStatusCode.OK); result.setStatus(status); + if (!Env.getCurrentEnv().isMaster()) { + status.setStatusCode(TStatusCode.NOT_MASTER); + status.addToErrorMsgs(NOT_MASTER_ERR_MSG); + result.setMasterAddress(getMasterAddress()); + LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG); + return result; + } + try { result = getBinlogLagImpl(request, clientAddr); } catch (UserException e) { @@ -3386,6 +3403,15 @@ public TGetMetaResult getMeta(TGetMetaRequest request) throws TException { TGetMetaResult result = new TGetMetaResult(); TStatus status = new TStatus(TStatusCode.OK); result.setStatus(status); + + if (!Env.getCurrentEnv().isMaster()) { + status.setStatusCode(TStatusCode.NOT_MASTER); + status.addToErrorMsgs(NOT_MASTER_ERR_MSG); + result.setMasterAddress(getMasterAddress()); + LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG); + return result; + } + try { result = getMetaImpl(request, clientAddr); } catch (UserException e) { @@ -3486,6 +3512,15 @@ public TGetBackendMetaResult getBackendMeta(TGetBackendMetaRequest request) thro TGetBackendMetaResult result = new TGetBackendMetaResult(); TStatus status = new TStatus(TStatusCode.OK); result.setStatus(status); + + if (!Env.getCurrentEnv().isMaster()) { + status.setStatusCode(TStatusCode.NOT_MASTER); + status.addToErrorMsgs(NOT_MASTER_ERR_MSG); + result.setMasterAddress(getMasterAddress()); + LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG); + return result; + } + try { result = getBackendMetaImpl(request, clientAddr); } catch (UserException e) { diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift index 42f4016d10d056..580852ba62c74a 100644 --- a/gensrc/thrift/FrontendService.thrift +++ b/gensrc/thrift/FrontendService.thrift @@ -1071,6 +1071,7 @@ struct TGetBinlogResult { 3: optional list binlogs 4: optional string fe_version 5: optional i64 fe_meta_version + 6: optional Types.TNetworkAddress master_address } struct TGetTabletReplicaInfosRequest { @@ -1149,6 +1150,7 @@ typedef TGetBinlogRequest TGetBinlogLagRequest struct TGetBinlogLagResult { 1: optional Status.TStatus status 2: optional i64 lag + 3: optional Types.TNetworkAddress master_address } struct TUpdateFollowerStatsCacheRequest { @@ -1276,6 +1278,7 @@ struct TGetMetaDBMeta { struct TGetMetaResult { 1: required Status.TStatus status 2: optional TGetMetaDBMeta db_meta + 3: optional Types.TNetworkAddress master_address } struct TGetBackendMetaRequest { @@ -1290,6 +1293,7 @@ struct TGetBackendMetaRequest { struct TGetBackendMetaResult { 1: required Status.TStatus status 2: optional list backends + 3: optional Types.TNetworkAddress master_address } service FrontendService {