Skip to content

[PB-6050] feat: hard delete files that were deleted 6 months ago#1010

Merged
apsantiso merged 3 commits into
masterfrom
feat/hard-delete-deleted-files-older-than-6months
Mar 26, 2026
Merged

[PB-6050] feat: hard delete files that were deleted 6 months ago#1010
apsantiso merged 3 commits into
masterfrom
feat/hard-delete-deleted-files-older-than-6months

Conversation

@apsantiso
Copy link
Copy Markdown
Collaborator

@apsantiso apsantiso commented Mar 25, 2026

Scheduled BullMQ job that hard-deletes files that have been in DELETED status for more than 6 months. Up to 10M files are going to be deleted per run in the first executions.

Changes

  • Processor deletes in batches of 100, up to MAX_BATCHES (100,000) per run, with a progress log every 500 batches.
  • The scheduler tries to enqueue a job every hour via BullMQ with a fixed jobId to prevent duplicate executions.
Limit  (cost=0.70..15.29 rows=100 width=16) (actual time=0.020..0.048 rows=100 loops=1)
  Buffers: shared hit=48
  ->  Index Only Scan using idx_user_status_updated_uuid on files  (cost=0.70..35043720.12 rows=240133977 width=16) (actual time=0.020..0.040 rows=100 loops=1)
        Index Cond: ((status = 'DELETED'::enum_files_status) AND (updated_at <= '2025-09-25 00:00:00'::timestamp without time zone))
        Heap Fetches: 7
        Buffers: shared hit=48
Planning:
  Buffers: shared hit=6
Planning Time: 0.198 ms
Execution Time: 0.067 ms

@apsantiso apsantiso requested a review from jzunigax2 as a code owner March 25, 2026 14:45
@apsantiso apsantiso requested a review from sg-gs March 25, 2026 14:56
@apsantiso apsantiso self-assigned this Mar 25, 2026
@apsantiso apsantiso added the enhancement New feature or request label Mar 25, 2026
Comment thread src/modules/file/file.repository.ts Outdated
sg-gs
sg-gs previously approved these changes Mar 26, 2026
@sonarqubecloud
Copy link
Copy Markdown

@apsantiso apsantiso merged commit 7c2c4f2 into master Mar 26, 2026
13 checks passed
@apsantiso apsantiso deleted the feat/hard-delete-deleted-files-older-than-6months branch March 26, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants