Skip to content

Commit b602ee6

Browse files
author
shiwenyan
committed
Fix OOM problem for PIPE.
1 parent a0dbf9b commit b602ee6

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -169,35 +169,32 @@ public List<Integer> checkUserPathPrivileges(
169169
String username, List<? extends PartialPath> allPath, PrivilegeType permission) {
170170
checkCacheAvailable();
171171
List<Integer> posList = new ArrayList<>();
172-
User user = iAuthorCache.getUserCache(username);
173-
if (user != null) {
174-
if (user.isOpenIdUser()) {
175-
return posList;
176-
}
177-
int pos = 0;
178-
for (PartialPath path : allPath) {
179-
if (!user.checkPathPrivilege(path, permission)) {
180-
boolean checkFromRole = false;
181-
for (String rolename : user.getRoleSet()) {
182-
Role cachedRole = iAuthorCache.getRoleCache(rolename);
183-
if (cachedRole == null) {
184-
return checkPathFromConfigNode(username, allPath, permission);
185-
}
186-
if (cachedRole.checkPathPrivilege(path, permission)) {
187-
checkFromRole = true;
188-
break;
189-
}
172+
User user = getUser(username);
173+
if (user.isOpenIdUser()) {
174+
return posList;
175+
}
176+
int pos = 0;
177+
for (PartialPath path : allPath) {
178+
if (!user.checkPathPrivilege(path, permission)) {
179+
boolean checkFromRole = false;
180+
for (String rolename : user.getRoleSet()) {
181+
Role cachedRole = iAuthorCache.getRoleCache(rolename);
182+
if (cachedRole == null) {
183+
checkRoleFromConfigNode(username, rolename);
184+
cachedRole = iAuthorCache.getRoleCache(rolename);
190185
}
191-
if (!checkFromRole) {
192-
posList.add(pos);
186+
if (cachedRole.checkPathPrivilege(path, permission)) {
187+
checkFromRole = true;
188+
break;
193189
}
194190
}
195-
pos++;
191+
if (!checkFromRole) {
192+
posList.add(pos);
193+
}
196194
}
197-
return posList;
198-
} else {
199-
return checkPathFromConfigNode(username, allPath, permission);
195+
pos++;
200196
}
197+
return posList;
201198
}
202199

203200
@Override
@@ -642,15 +639,6 @@ private TPermissionInfoResp checkPrivilegeFromConfigNode(TCheckUserPrivilegesReq
642639
return permissionInfoResp;
643640
}
644641

645-
private List<Integer> checkPathFromConfigNode(
646-
String username, List<? extends PartialPath> allPath, PrivilegeType permission) {
647-
TCheckUserPrivilegesReq req =
648-
new TCheckUserPrivilegesReq(
649-
username, PrivilegeModelType.TREE.ordinal(), permission.ordinal(), false);
650-
req.setPaths(AuthUtils.serializePartialPathList(allPath));
651-
return checkPrivilegeFromConfigNode(req).getFailPos();
652-
}
653-
654642
private boolean checkRoleFromConfigNode(String username, String rolename) {
655643
TAuthorizerReq req = new TAuthorizerReq();
656644
// just reuse authorizer request. only need username and rolename field.

0 commit comments

Comments
 (0)