tju-yxq opened a new pull request, #5310:
URL: https://github.com/apache/rocketmq-dashboard/pull/5310

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5309
   
   ### Brief Description
   
   Adds the missing scheduled retention sweep for audit logs, mirroring the 
established `studio.query-history` / `studio.ai.conversation` pattern:
   
   - New `AuditProperties` (`studio.audit.retention-days`, env 
`STUDIO_AUDIT_RETENTION_DAYS`).
   - `AuditService.scheduledCleanup()` runs hourly 
(`studio.audit.cleanup-interval`, default `PT1H`) and calls the same bounded 
`cleanupLogs` the manual endpoint uses — 500-row batches, at most 20 per pass, 
so a large backlog drains over successive sweeps without a long-running 
statement.
   - **Default 0 — keep forever.** Deliberately different from the diagnostic 
tables that default to 90 days: audit rows are compliance evidence, and an 
upgrade must never start silently deleting them. Deployments opt in.
   - Retention above the 365-day maximum the manual endpoint enforces is 
clamped with a warning instead of throwing every hour; repository failures are 
logged and swallowed (retention is hygiene, not an application error).
   - The manual cleanup endpoint, the audit page and the endpoint's 1..365 
validation are unchanged.
   
   ### How Did You Test This Change?
   
   Focused suite on the branch (Windows, Java 21; based on `rocketmq-studio` at 
`6a68042f`):
   
   ```
   cd server && mvn '-Dtest=AuditServiceTest,AuditControllerTest' test
   [INFO] Tests run: 23, Failures: 0, Errors: 0, Skipped: 0 -- in 
...AuditServiceTest
   [INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0 -- in 
...AuditControllerTest
   [INFO] BUILD SUCCESS
   ```
   
   Four new service tests: the sweep performs no repository access at all while 
retention is disabled (the default); with retention 90 it calls the bounded 
delete with a cutoff between 90 and 91 days in the past and the same 500×20 
bounds; retention 3650 is clamped so the cutoff stays within the 365-day 
maximum; and a repository failure is logged and swallowed rather than 
propagating. The 12 existing controller tests confirm the manual endpoint is 
untouched. Checkstyle ran with the build (it is bound to the validate phase).
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
(no UI text — backend-only change)
   - [x] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [x] New source files carry the ASF license header
   - [x] Documentation touched where behaviour changed 
(`server/src/main/resources/application.yml` documents the new property and its 
keep-forever default)
   


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