jerryshao commented on code in PR #4055:
URL: https://github.com/apache/gravitino/pull/4055#discussion_r1681009217


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java:
##########
@@ -221,6 +224,39 @@ public <E extends Entity & HasIdentifier> UserEntity 
updateUser(
     return newEntity;
   }
 
+  public List<UserEntity> listUsersByNamespace(Namespace namespace) {
+    AuthorizationUtils.checkUserNamespace(namespace);
+
+    List<UserEntity> userEntities = Lists.newArrayList();
+    String metalakeName = namespace.level(0);
+    List<UserPO> userPOs = Lists.newArrayList();
+    AtomicLong metalakeId = new AtomicLong();
+    SessionUtils.doMultipleWithoutCommit(
+        () -> {
+          Long id =
+              SessionUtils.doWithoutCommitAndFetchResult(
+                  MetalakeMetaMapper.class,
+                  mapper -> mapper.selectMetalakeIdMetaByName(metalakeName));
+          if (id == null) {
+            throw new NoSuchEntityException(
+                NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+                Entity.EntityType.METALAKE.name().toLowerCase(),
+                metalakeName);
+          }
+          metalakeId.set(id);
+        },
+        () ->
+            userPOs.addAll(
+                SessionUtils.doWithoutCommitAndFetchResult(
+                    UserMetaMapper.class,
+                    mapper -> 
mapper.listUserPOsByMetalakeId(metalakeId.get()))));

Review Comment:
   I think we don't have to use transaction here, simply because we don't use 
select for update, so the transaction is not useful and will lead to dead lock.



-- 
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]

Reply via email to