feat(listener): add scheduled database cleanup job for expired temporary records - #910
Merged
Abd-Standard merged 2 commits intoOct 1, 2026
Merged
Conversation
…ary records. Closes Core-Foundry#845. Configurable CLEANUP_ENABLED/CLEANUP_INTERVAL_MS/CLEANUP_RETENTION_DAYS with validated schema; bounded batched per-table purges of expired idempotency keys, aged processed_events/dead-letter/execution-log/rate-limit rows and DEACTIVATED backpressure; active records (PENDING/PROCESSING-linked logs, future-dated keys, ACTIVATED records, live cursors/templates) never removed; per-table failure isolation with partial counts; per-run logged counts with correlation id; graceful shutdown; operator docs. Archive/metrics ownership delegated, not duplicated.
|
@najeebullahii Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #845.
Changes:
DatabaseCleanupJob(new service file, registered via the existing WorkerManager with graceful shutdown) purging expired temporary data in bounded 1,000-row batched transactions: idempotency keys pastexpires_ator status EXPIRED, agedprocessed_events, aged dead-letter and execution-log rows, elapsedrate_limit_eventswindows, and DEACTIVATED backpressure records.CLEANUP_ENABLED(default true),CLEANUP_INTERVAL_MS(default 3600000, min 60000),CLEANUP_RETENTION_DAYS(default 30, min 1) validated through the existing config schema; pre-existing per-table retention env vars remain optional overrides;listener/.env.exampleupdated.ArchiveServiceremains sole owner of scheduled-notification archival and age-based, status-agnostic archive purging (which covers EXPIRED rows from in-flight feat(listener): expire scheduled notifications past a configured deadline #893 once merged);NotificationMetricsRunnerowns metrics snapshots. The job logs delegated/skipped owners instead of running competing purges.Testing: focused suites green (53/53); Prettier and
git diff --checkclean; no migration added; no package/lockfile changes.Pre-existing baseline (verified against a stashed clean tree, untouched by this PR): six failures in legacy cleanup/archive tests (two EventRegistry malformed-SCVal fixtures, one legacy timer-call count, three archive API response-shape assertions); full
npm testred on main (~55 failing suites: request-id.ts syntax error, Stellar XDR test setup, config secret validation);npm run lintfails on index.ts/request-id.ts/security-headers.ts/discord-notification.ts — index.ts contains a pre-existing malformed startup block which this PR wires around minimally without rewriting; lockfile out of sync with package.json (this PR modifies neither).