yuqi1129 commented on code in PR #2873:
URL: https://github.com/apache/gravitino/pull/2873#discussion_r1975070971
##########
core/src/main/java/org/apache/gravitino/authorization/PermissionManager.java:
##########
@@ -67,7 +69,10 @@ User grantRolesToUser(String metalake, List<String> roles,
String user) {
try {
List<RoleEntity> roleEntitiesToGrant = Lists.newArrayList();
for (String role : roles) {
- roleEntitiesToGrant.add(roleManager.getRole(metalake, role));
+ TreeLockUtils.doWithTreeLock(
+ AuthorizationUtils.ofRole(metalake, role),
+ LockType.READ,
+ () -> roleEntitiesToGrant.add(roleManager.getRole(metalake,
role)));
Review Comment:
Locking the parent node with read type is NOT correct logically. For
example, if we lock the parent lock with a read lock, other threads can still
modify the role when this method is loading the role, so if we are going to use
the namespace lock, the lock type should be changed to `WRITE`. Is that
acceptable to you?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]