Skip to content

Commit

Permalink
[hotfix](priv) Fix restore snapshot user priv with add cluster in Use…
Browse files Browse the repository at this point in the history
…rIdentity (apache#26969) (apache#27210)

Signed-off-by: Jack Drogon <jack.xsuperman@gmail.com>
  • Loading branch information
JackDrogon authored and gnehil committed Dec 4, 2023
1 parent a694382 commit 96f1aa4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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 @@ -2894,15 +2894,16 @@ 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, "%");
currentUserIdentity.setIsAnalyzed();
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

0 comments on commit 96f1aa4

Please sign in to comment.