fix(downloads): purge old processing jobs via a hosted cleanup worker#641
Open
kevinheneveld wants to merge 1 commit into
Open
fix(downloads): purge old processing jobs via a hosted cleanup worker#641kevinheneveld wants to merge 1 commit into
kevinheneveld wants to merge 1 commit into
Conversation
IDownloadProcessingJobService.CleanupOldJobsAsync existed but had no caller, so the DownloadProcessingJobs table grew unbounded on long-running instances. Every queue-snapshot reconciliation queries this table (pending/all job download IDs for completed DDL items), so the backlog also added steady per-snapshot cost. Add DownloadProcessingJobCleanupService, a hosted BackgroundService that purges terminal (Completed/Failed) jobs older than a 7-day retention window shortly after startup and then daily. Retention is a constant to keep this change migration-free; making it configurable is a follow-up. Tests: terminal jobs past retention are removed while recent and non-terminal jobs are retained; no-op when nothing is eligible; service is registered as a hosted service. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Addresses the 3a (job retention) portion of #640.
IDownloadProcessingJobService.CleanupOldJobsAsync(retentionDays)already existed (and is implemented inEfDownloadProcessingJobRepository) but had no caller, soDownloadProcessingJobsgrew unbounded on long-running instances — and every queue-snapshot reconciliation that queries this table pays for the bloat.This adds
DownloadProcessingJobCleanupService, a hostedBackgroundServicethat purges terminal (Completed/Failed) jobs older than a 7-day retention window shortly after startup and then daily.Notes
CleanupOldJobsAsyncdefault) to keep this change migration-free; making it configurable is an easy follow-up.RunCleanupAsyncso it can be exercised directly in tests without driving the background loop.HostedServiceRegistrationExtensions.Tests
Does not touch the 3b (orphan terminalization) part of #640 — that's a separate, more behavioral change and is left for discussion on the issue.