Delete archived clients and snapshots in one transaction - #18
Merged
Conversation
The two deletes ran as separate statements, so a connection drop between them left the clients gone and the snapshots behind. The next tick would re-read those snapshots with no clients attached and overwrite the object at the same key with a client-less version, silently losing the client rows that were already archived correctly. The window is real rather than theoretical: about 20% of archive jobs are currently failing on connection loss while the backlog drains, and one of them failed at the client delete specifically. No object has been rewritten so far — LastModified is still monotonic with id across all ~2900 objects in the bucket. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
archiveBatchdeleted the client rows and the snapshot rows as two separate statements, so a connection drop between them left the clients gone while the snapshots remained — and the next tick would re-read those snapshots with no clients attached and overwrite the object at the same key with a client-less version, silently losing client rows that had already been archived correctly. This wraps both deletes in a singleprisma.$transaction, keeping clients first to avoid a per-row cascade from the snapshots.The window is real rather than theoretical: while the backlog drains, roughly 20% of archive jobs are failing on database connection loss, and one of them failed at the client delete specifically. Nothing has been lost yet — I verified that
LastModifiedis still monotonic with id across all ~2900 objects in the bucket, so no object has been rewritten.🤖 Generated with Claude Code