[hotfix](priv) Fix restore snapshot user priv with add cluster in UserIdentity (#26969)

Signed-off-by: Jack Drogon <jack.xsuperman@gmail.com>
This commit is contained in:
Jack Drogon
2023-11-14 19:48:54 +08:00
committed by GitHub
parent cdef768629
commit 4889c1d029
2 changed files with 5 additions and 2 deletions

View File

@ -181,6 +181,7 @@ public class DBBinlog {
if (tableId >= 0) {
TableBinlog tableBinlog = tableBinlogMap.get(tableId);
if (tableBinlog == null) {
LOG.warn("table binlog not found. tableId: {}", tableId);
status.setStatusCode(TStatusCode.BINLOG_NOT_FOUND_TABLE);
return Pair.of(status, null);
}
@ -200,6 +201,7 @@ public class DBBinlog {
if (tableId >= 0) {
TableBinlog tableBinlog = tableBinlogMap.get(tableId);
if (tableBinlog == null) {
LOG.warn("table binlog not found. tableId: {}", tableId);
status.setStatusCode(TStatusCode.BINLOG_NOT_FOUND_TABLE);
return Pair.of(status, null);
}

View File

@ -3071,14 +3071,15 @@ public class FrontendServiceImpl implements FrontendService.Iface {
}
ctx.setCluster(cluster);
ctx.setQualifiedUser(request.getUser());
UserIdentity currentUserIdentity = new UserIdentity(request.getUser(), "%");
String fullUserName = ClusterNamespace.getFullName(cluster, request.getUser());
UserIdentity currentUserIdentity = new UserIdentity(fullUserName, "%");
ctx.setCurrentUserIdentity(currentUserIdentity);
Analyzer analyzer = new Analyzer(ctx.getEnv(), ctx);
restoreStmt.analyze(analyzer);
DdlExecutor.execute(Env.getCurrentEnv(), restoreStmt);
} catch (UserException e) {
LOG.warn("failed to get snapshot info: {}", e.getMessage());
LOG.warn("failed to restore: {}", e.getMessage(), e);
status.setStatusCode(TStatusCode.ANALYSIS_ERROR);
status.addToErrorMsgs(e.getMessage());
} catch (Throwable e) {