Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](ccr) Mark getBinlog,getBinlogLag,getMeta,getBackendMeta as from master (#27211) #27227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,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) {
Expand Down Expand Up @@ -2954,6 +2963,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) {
Expand Down Expand Up @@ -3062,6 +3079,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) {
Expand Down Expand Up @@ -3162,6 +3188,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) {
Expand Down
4 changes: 4 additions & 0 deletions gensrc/thrift/FrontendService.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ struct TGetBinlogResult {
3: optional list<TBinlog> binlogs
4: optional string fe_version
5: optional i64 fe_meta_version
6: optional Types.TNetworkAddress master_address
}

struct TGetTabletReplicaInfosRequest {
Expand Down Expand Up @@ -1093,6 +1094,7 @@ typedef TGetBinlogRequest TGetBinlogLagRequest
struct TGetBinlogLagResult {
1: optional Status.TStatus status
2: optional i64 lag
3: optional Types.TNetworkAddress master_address
}

struct TUpdateFollowerStatsCacheRequest {
Expand Down Expand Up @@ -1191,6 +1193,7 @@ struct TGetMetaDBMeta {
struct TGetMetaResult {
1: required Status.TStatus status
2: optional TGetMetaDBMeta db_meta
3: optional Types.TNetworkAddress master_address
}

struct TGetBackendMetaRequest {
Expand All @@ -1205,6 +1208,7 @@ struct TGetBackendMetaRequest {
struct TGetBackendMetaResult {
1: required Status.TStatus status
2: optional list<Types.TBackend> backends
3: optional Types.TNetworkAddress master_address
}

service FrontendService {
Expand Down