Skip to content

Tech: corrige des problèmes avec le soft delete des blobs openstack#13421

Merged
LeSim merged 8 commits into
mainfrom
track_and_discard_purged_blob
Jul 13, 2026
Merged

Tech: corrige des problèmes avec le soft delete des blobs openstack#13421
LeSim merged 8 commits into
mainfrom
track_and_discard_purged_blob

Conversation

@LeSim

@LeSim LeSim commented Jul 6, 2026

Copy link
Copy Markdown
Member

Corrige plusieurs soucis :

Détection d'openstack dans delayed_purge
DelayedPurged regardait soit si la gem openstack était présente, soit si le service était openstack, pour décider si on pouvait utiliser les features openstack pour soft delete. Or nous utilisons en prod openstack + s3, le test n'était plus bon,

=> on se base maintenant directement sur le service utilisé renseigné sur le blob

Nombre de blob croissant
On ne supprime plus directement de blob : on supprime les attachments et on place un flag de suppression dans X jours sur le fichier openstack. Les blobs sont gardés en base et dit orphelins

  • Si les blobs ont été créés il y a moins d'une semaine, le job PurgeUnattachedBlobs les reprends et les ... purge_later (retour dans DelayedPurged ...) 😿 .
  • les autres reste dans la table

=> soluce :

  • on ajoute la colonne soft_deleted_at a la table des blobs (2min de migration pour l'index sur la dev)
  • PurgeUnattachedBlobs exclue les déjà soft deleted
  • on rajoute PurgeSoftDeletedBlobsJob qui supprimer les soft deleted blobs après le délai de retention

les variants éternels

Les variants ne sont jamais supprimés : delayed_purged utilise service.delete_prefixed("variants/#{key}/") ... hors les variants ne sont pas stockés sous la clé "variant", mais sous une entrée séparée dans la table active_storage_variants (conf track_variants)

=> on mark aussi ces variants pour un soft delete

Stats:

  • 2 Millions de blob par semaine

RAF:

Prochaine PR

  • faire un job qui reparcours tous les blobs et supprime ceux les orphelins
  • gerer le soft delete s3

@LeSim LeSim added the bug label Jul 6, 2026
@LeSim LeSim moved this to En cours in The Kanban Jul 6, 2026
@LeSim
LeSim force-pushed the track_and_discard_purged_blob branch 2 times, most recently from 2050930 to 38c5798 Compare July 7, 2026 13:22
@LeSim
LeSim marked this pull request as ready for review July 7, 2026 13:24
Comment thread app/jobs/delayed_purge_job.rb
Comment thread app/jobs/delayed_purge_job.rb
@LeSim
LeSim force-pushed the track_and_discard_purged_blob branch 2 times, most recently from 185c9d7 to b9a3745 Compare July 8, 2026 09:08
@LeSim
LeSim enabled auto-merge July 8, 2026 09:09
@LeSim
LeSim force-pushed the track_and_discard_purged_blob branch from b9a3745 to 89d5847 Compare July 8, 2026 09:13
@LeSim
LeSim added this pull request to the merge queue Jul 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 8, 2026
@LeSim
LeSim added this pull request to the merge queue Jul 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 9, 2026
@LeSim
LeSim added this pull request to the merge queue Jul 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 13, 2026
LeSim added 3 commits July 13, 2026 10:00
… on openstack

previously, it was base on if the whole storage_service was bind to openstack.
But we are simultaneously using s3 and swift, and keeping the active_storage.service == :openstack
The Sentry call referenced an undefined `headers` variable, raising a
NameError whenever copy_object returned a non-201 status. Extract the
headers hash sent to copy_object and reuse it.
@LeSim
LeSim force-pushed the track_and_discard_purged_blob branch from 89d5847 to d01f1d0 Compare July 13, 2026 08:01
LeSim added 5 commits July 13, 2026 10:08
The OpenStack soft delete only expires the file (X-Delete-At) and leaves
the blob row in place. Stamp soft_delete_at so the leaked rows can be
tracked and cleaned up later.
… job

Soft-deleted blobs stay unattached with their row intact, so this job
kept re-enqueuing them nightly and resetting X-Delete-At. Ignore blobs
that already have soft_delete_at set.
`delete_multiple_objects` built its request body with `URI.encode`, removed in Ruby 3.0, raising NoMethodError on any non-empty list. Reopen the method to use `URI::DEFAULT_PARSER.escape` (same escaping, keeps the container/object slash literal). Canary specs fail if either Ruby or fog stops making the patch necessary.
@LeSim
LeSim force-pushed the track_and_discard_purged_blob branch from d01f1d0 to 1107820 Compare July 13, 2026 08:09
@LeSim
LeSim added this pull request to the merge queue Jul 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 13, 2026
@LeSim
LeSim added this pull request to the merge queue Jul 13, 2026
Merged via the queue into main with commit c57f56f Jul 13, 2026
20 checks passed
@LeSim
LeSim deleted the track_and_discard_purged_blob branch July 13, 2026 09:50
LeSim added a commit that referenced this pull request Jul 16, 2026
Re-scans the whole blob stock by id range, targeting only openstack
blobs, and hard-deletes the orphans: their variants, the parent blobs,
and the corresponding files on the bucket via delete_multiple_objects.

Ref #13421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: En cours

Development

Successfully merging this pull request may close these issues.

2 participants