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

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

Merged
merged 1 commit into from
Nov 14, 2023
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
Fix restore snapshot user priv with add cluster in UserIdentity
Signed-off-by: Jack Drogon <jack.xsuperman@gmail.com>
  • Loading branch information
JackDrogon committed Nov 14, 2023
commit 61ad3bc35703117e1939694d6316b5fb8ef39c75
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public Pair<TStatus, TBinlog> getBinlog(long tableId, long prevCommitSeq) {
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);
}
Expand All @@ -200,6 +201,7 @@ public Pair<TStatus, Long> getBinlogLag(long tableId, long prevCommitSeq) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3071,14 +3071,15 @@ private TRestoreSnapshotResult restoreSnapshotImpl(TRestoreSnapshotRequest reque
}
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) {
Expand Down