Skip to content

F-027 (P3) — ScanCleanupBackgroundService loads all rows to be deleted into memory before RemoveRange #81

Description

@LarsLaskowski

Severity: 🟡 · Criterion: K7 / K6 · Phase: P3 · Status (review): 🆕

File(s): src/DockerUpdateGuard/Images/ScanCleanupBackgroundService.cs:103-167

Finding

Each category (old samples, snapshots, findings, scan runs, tag candidates) is
materialized via ToListAsync() and then RemoveRange'd. Cleanup specifically targets large backlogs,
so very large quantities are loaded into memory. ExecuteDeleteAsync (in dependency
order or with DB cascade) avoids the materialization. (The materialization may be deliberate
to let EF handle the dependent deletions across the graph.)

Impact

Unnecessary materialization; at scale it undermines the purpose of the cleanup.
Rarely executed (CleanupIntervalMinutes), hence 🟡.

Recommendation

Switch to ExecuteDeleteAsync in dependency order or use the FK cascade
rules (P4).


Auto-generated from the repository code review. Source of truth: docs/review/findings.mdF-027 (P3), branch review/review-analysis-plan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions