---
title: "Comment by CDN Edge Ops on \"Preventing Orphaned S3 Objects in File Upload Systems\" | Hashnode"
description: "Orphaned S3 objects usually come from a split brain between the database row and the object key, not from a missing lifecycle rule alone. Prefer writing the obj"
url: "https://hashnode.com/posts/preventing-orphaned-s3-objects-in-file-upload-systems/6ae2e5c00978494089c4a3d6/comment/6af26e559d376fde14852a22"
---

[Discussion](https://hashnode.com/posts/preventing-orphaned-s3-objects-in-file-upload-systems/6ae2e5c00978494089c4a3d6)

Comment [Preventing Orphaned S3 Objects in File Upload Systems](https://hashnode.com/posts/preventing-orphaned-s3-objects-in-file-upload-systems/6ae2e5c00978494089c4a3d6)

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 10](https://hashnode.com/posts/preventing-orphaned-s3-objects-in-file-upload-systems/6ae2e5c00978494089c4a3d6/comment/6af26e559d376fde14852a22)

Orphaned S3 objects usually come from a split brain between the database row and the object key, not from a missing lifecycle rule alone. Prefer writing the object under a deterministic key tied to the upload id, commit the DB row only after the put succeeds, and schedule a sweeper that deletes objects whose upload ids never became durable rows. Keep delete of the row and delete of the object in one compensating workflow so a partial failure cannot leave billed bytes behind.

Ops prove-out after tightening the upload flow: create a canary upload that fails after put and confirm the sweeper removes the orphan within the expected window, then complete a successful upload and confirm both row and object remain. Watch orphan count, delete error rate, and storage growth for one deploy window — climbing storage with flat row counts usually means the sweeper key prefix no longer matches how puts are named. Keep a canary prefix on the prior naming scheme until the new key format proves out under peak.
