Skip to content

πŸ”§ fix(uploads): purgeUnreferenced bucket.delete should no-op on already-deleted blobs (race with retention jobs)Β #4018

Description

@PierreBrisorgueil

What β€” extend remove()'s not-found no-op treatment to purgeUnreferenced()'s own bucket.delete() call.

Why β€” a consumer running both the sweep and an independent retention job can race: the other job deletes a blob between the sweep's candidate scan and its delete pass. Today that surfaces as a recurring deleteFailed/error-log entry on every such race β€” exactly the noise class remove()'s no-op path (same file) was built to prevent. Fails closed (nothing wrongly deleted); noise-only.

Scope β€” modules/uploads/repositories/uploads.repository.js purgeUnreferenced(): catch the GridFS not-found error on bucket.delete() β†’ debug log + count as already-gone, continue the pass; genuine bucket failures still surface. One unit test: mid-sweep concurrent deletion β†’ no error log, sweep completes, counts accurate.

Surfaced by post-merge review of #4017 (2026-08-05).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions