kumaab commented on code in PR #253:
URL: https://github.com/apache/ranger/pull/253#discussion_r1212601478


##########
security-admin/src/main/java/org/apache/ranger/biz/XUserMgr.java:
##########
@@ -2400,6 +2426,31 @@ public synchronized void deleteXUser(Long id, boolean 
force) {
                }
        }
 
+       public void forceDeleteUsers(List<VXUser> users){
+               long startTime = Time.now();
+               for(VXUser user: users){
+                       Long userId = user.getId();
+                       TransactionTemplate txTemplate = new 
TransactionTemplate(txManager);
+                       
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
+                       try {
+                               txTemplate.execute(new 
TransactionCallback<Object>() {
+                                       @Override
+                                       public Object 
doInTransaction(TransactionStatus status) {
+                                               deleteXUser(userId, true);
+                                               return null;
+                                       }
+                               });
+                       } catch (Throwable ex) {
+                               logger.error("forceDeleteUsers(): Failed to 
delete user id: " + userId + " ", ex);
+                               throw new RuntimeException(ex);

Review Comment:
   Sure, I'll revise the PR to continue with deletes despite failures. 
   
   I believe getting the usernames for all users deleted/failed deletes is an 
overhead since this would result in another db call(with new jpa query), and 
ignoring the rare occurrence of transaction exceptions(in which we might not 
get the logs from deleteUser()), info regarding every user is already logged as 
part of deleteUser() where we print the username of the user getting deleted. 
For debugging purposes in case of transaction failures, username of the user is 
still retrievable using the userid in the catch block.
   
    



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