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 dbc985c48a..6a99e38b15 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 @@ -2796,6 +2796,15 @@ public class FrontendServiceImpl implements FrontendService.Iface { 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) { @@ -3137,6 +3146,14 @@ public class FrontendServiceImpl implements FrontendService.Iface { 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) { @@ -3385,6 +3402,15 @@ public class FrontendServiceImpl implements FrontendService.Iface { 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) { @@ -3524,6 +3550,15 @@ public class FrontendServiceImpl implements FrontendService.Iface { 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 7552167ff9..f7c94b37e9 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 } struct TGetColumnInfoRequest {