Skip to content

feat(preprod): Delete snapshot objectstore data on artifact deletion#111972

Merged
NicoHinderling merged 6 commits intomasterfrom
nicohinderling/feat/snapshot-objectstore-deletion
Apr 1, 2026
Merged

feat(preprod): Delete snapshot objectstore data on artifact deletion#111972
NicoHinderling merged 6 commits intomasterfrom
nicohinderling/feat/snapshot-objectstore-deletion

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

Adds objectstore cleanup to the artifact deletion path in delete_artifacts_and_eap_data.

Previously, only DB records and EAP trace data were cleaned up when deleting preprod artifacts. Snapshot images, manifests, comparison manifests, and diff masks stored in objectstore were left to expire via 30-day TTL — meaning deleted snapshot data remained accessible for up to a month.

Now, before the DB cascade runs, we read each snapshot's manifest to discover all associated objectstore keys (individual images by content hash, the manifest itself, comparison manifests, and diff mask PNGs), deduplicate them, and delete them in parallel using ContextPropagatingThreadPoolExecutor(max_workers=8). Individual key deletion failures are logged but non-blocking since TTL expiration serves as the fallback.

The implementation is split into three module-level functions:

  • _collect_snapshot_objectstore_keys — queries snapshot metrics and comparisons, reads manifests to enumerate all keys
  • _delete_objectstore_key — thread worker that deletes a single key
  • _delete_snapshot_objectstore_data — orchestrator that deduplicates keys and dispatches parallel deletes

Previously, delete_artifacts_and_eap_data only cleaned up DB records and
EAP trace data. Snapshot images, manifests, comparison manifests, and
diff masks stored in objectstore were left to expire via 30-day TTL.

This adds objectstore cleanup to the deletion path: before the DB
cascade, we read manifests to discover all associated keys (images,
diff masks, comparison data) and delete them in parallel via a thread
pool. Failures are logged but non-blocking since TTL is the fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 1, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review April 1, 2026 00:39
@NicoHinderling NicoHinderling requested a review from a team as a code owner April 1, 2026 00:39
Image keys are content-addressed and shared across snapshots in the
same project. Eagerly deleting them when one artifact is removed
breaks image display for other active snapshots referencing the same
content_hash. Images already expire via 30-day objectstore TTL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NicoHinderling NicoHinderling force-pushed the nicohinderling/feat/snapshot-objectstore-deletion branch from 4f60d38 to a078ad1 Compare April 1, 2026 18:53
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Move objectstore key collection before bulk_delete_artifacts so DB
records are never left pointing at already-deleted objectstore data.
Previously, objectstore data was deleted first — if the subsequent DB
deletion failed, snapshots and comparisons would reference missing keys.

Now the flow is: collect keys → delete DB records → delete objectstore
keys. TTL expiry still serves as fallback if objectstore deletes fail.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@NicoHinderling NicoHinderling merged commit 410cbb9 into master Apr 1, 2026
65 checks passed
@NicoHinderling NicoHinderling deleted the nicohinderling/feat/snapshot-objectstore-deletion branch April 1, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants