-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75371/
-----------------------------------------------------------

Review request for ranger, Dineshkumar Yadav, Kishor Gollapalliwar, Abhay 
Kulkarni, Madhan Neethiraj, Mehul Parikh, Pradeep Agrawal, Ramesh Mani, sanket 
shelar, Sailaja Polavarapu, and Velmurugan Periasamy.


Bugs: RANGER-5154
    https://issues.apache.org/jira/browse/RANGER-5154


Repository: ranger


Description
-------

Functionality to delete records from x_auth_sess table via api is not working.


Upon hitting below curl command we get error

curl -u admin:Admin123 -H "Accept: application/json" -H "Content-Type: 
application/json" -X DELETE 
'http://localhost:6080/service/public/v2/api/server/purge/records?type=login_records&retentionDays=5'
error

{"statusCode":1,"msgDesc":"Exception [EclipseLink-4002] (Eclipse Persistence 
Services - 2.7.12.v20230209-e5c4074ef3): 
org.eclipse.persistence.exceptions.DatabaseException\nInternal Exception: 
org.postgresql.util.PSQLException: ERROR: relation \"x_trx_log\" does not 
exist\n  Position: 8\nError Code: 0\nCall: UPDATE x_trx_log SET SESS_ID = ? 
WHERE (CREATE_TIME < ?)\n\tbind => [2 parameters bound]\nQuery: 
UpdateAllQuery(name=\"XXTrxLog.updateSessIdWithNull\" referenceClass=XXTrxLog 
sql=\"UPDATE x_trx_log SET SESS_ID = ? WHERE (CREATE_TIME < ?)\")"}


Diffs
-----

  security-admin/src/main/java/org/apache/ranger/db/XXAuthSessionDao.java 
658614e01 
  security-admin/src/main/resources/META-INF/jpa_named_queries.xml 56eefba40 


Diff: https://reviews.apache.org/r/75371/diff/1/


Testing
-------

Approach 1: Ranger Admin Startup Configuration

Added "ranger.admin.init.purge.login_records" and 
"ranger.admin.init.purge.login_records.retention.days" to 
ranger-admin-site.xml, setting the retention period to 6 days and Restarted the 
Ranger Admin service.

Verified the x_auth_sess table after the restart, confirming that entries older 
than 6 days were successfully removed.

Approach-2: REST API approach

Executed the following curl command to trigger the deletion of login records 
older than 5 days via the Ranger REST API:
curl -u admin:Admin123 -H "Accept: application/json" -H "Content-Type: 
application/json" -X DELETE 
'http://localhost:6080/service/public/v2/api/server/purge/records?type=login_records&retentionDays=5'

The request was successfully processed.

Manually verified the x_auth_sess table, confirming that older entries were 
deleted.

Observed the following log entry in the Ranger log file:

2025-03-13 10:14:07,473 [http-nio-6080-exec-4] INFO [ServiceDBStore.java:2655] 
Deleted 10 records from x_auth_sess that are older than 5 days


Thanks,

Rakesh Gupta

Reply via email to