branch-2.1: [enhance](auth)Reduce the scope of permission locks #46115 (#46451)

Cherry-picked from #46115

Co-authored-by: zhangdong <zhangdong@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-01-06 18:51:09 +08:00
committed by GitHub
parent 4b69673e4e
commit 53889cbbb6

View File

@ -595,11 +595,11 @@ public class Auth implements Writable {
private void grantInternal(UserIdentity userIdent, String role, TablePattern tblPattern, PrivBitSet privs,
Map<ColPrivilegeKey, Set<String>> colPrivileges, boolean errOnNonExist, boolean isReplay)
throws DdlException {
if (!isReplay) {
checkTablePatternExist(tblPattern, privs);
}
writeLock();
try {
if (!isReplay) {
checkTablePatternExist(tblPattern, privs);
}
if (role == null) {
if (!doesUserExist(userIdent)) {
throw new DdlException("user " + userIdent + " does not exist");