(enhancement)[fe] Add isMaster() check for FrontendService (#24412)
* In `FrontendServiceImpl` service, the api which need to write editlog need add `isMaster()` check
This commit is contained in:
@ -1216,7 +1216,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get binlog: {}", NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1321,6 +1321,13 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
TLoadTxnCommitResult result = new TLoadTxnCommitResult();
|
||||
TStatus status = new TStatus(TStatusCode.OK);
|
||||
result.setStatus(status);
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to loadTxnPreCommit:{}, request:{}, backend:{}",
|
||||
NOT_MASTER_ERR_MSG, request, clientAddr);
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
loadTxnPreCommitImpl(request);
|
||||
} catch (UserException e) {
|
||||
@ -1421,6 +1428,14 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
TLoadTxn2PCResult result = new TLoadTxn2PCResult();
|
||||
TStatus status = new TStatus(TStatusCode.OK);
|
||||
result.setStatus(status);
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to loadTxn2PC:{}, request:{}, backend:{}",
|
||||
NOT_MASTER_ERR_MSG, request, clientAddr);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
loadTxn2PCImpl(request);
|
||||
} catch (UserException e) {
|
||||
@ -1499,6 +1514,14 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
TLoadTxnCommitResult result = new TLoadTxnCommitResult();
|
||||
TStatus status = new TStatus(TStatusCode.OK);
|
||||
result.setStatus(status);
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to loadTxnCommit:{}, request:{}, backend:{}",
|
||||
NOT_MASTER_ERR_MSG, request, clientAddr);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!loadTxnCommitImpl(request)) {
|
||||
// committed success but not visible
|
||||
@ -1575,7 +1598,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get binlog: {}", NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get commitTxn: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1684,6 +1707,13 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
TLoadTxnRollbackResult result = new TLoadTxnRollbackResult();
|
||||
TStatus status = new TStatus(TStatusCode.OK);
|
||||
result.setStatus(status);
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to loadTxnRollback:{}, request:{}, backend:{}",
|
||||
NOT_MASTER_ERR_MSG, request, clientAddr);
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
loadTxnRollbackImpl(request);
|
||||
} catch (UserException e) {
|
||||
@ -1752,11 +1782,10 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
TRollbackTxnResult result = new TRollbackTxnResult();
|
||||
TStatus status = new TStatus(TStatusCode.OK);
|
||||
result.setStatus(status);
|
||||
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get binlog: {}", NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get rollbackTxn: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2743,7 +2772,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get binlog: {}", NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get getSnapshot: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2829,7 +2858,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get binlog: {}", NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get restoreSnapshot: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2933,6 +2962,12 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
TGetMasterTokenResult result = new TGetMasterTokenResult();
|
||||
TStatus status = new TStatus(TStatusCode.OK);
|
||||
result.setStatus(status);
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
status.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to get getMasterToken: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
checkPassword(request.getCluster(), request.getUser(), request.getPassword(), clientAddr);
|
||||
@ -3067,6 +3102,12 @@ public class FrontendServiceImpl implements FrontendService.Iface {
|
||||
long tableId = request.getTableId();
|
||||
TCreatePartitionResult result = new TCreatePartitionResult();
|
||||
TStatus errorStatus = new TStatus(TStatusCode.RUNTIME_ERROR);
|
||||
if (!Env.getCurrentEnv().isMaster()) {
|
||||
errorStatus.setStatusCode(TStatusCode.NOT_MASTER);
|
||||
errorStatus.addToErrorMsgs(NOT_MASTER_ERR_MSG);
|
||||
LOG.error("failed to createPartition: {}", NOT_MASTER_ERR_MSG);
|
||||
return result;
|
||||
}
|
||||
|
||||
Database db = Env.getCurrentEnv().getInternalCatalog().getDbNullable(dbId);
|
||||
if (db == null) {
|
||||
|
||||
Reference in New Issue
Block a user