Skip to content

Delete archived clients and snapshots in one transaction - #18

Merged
needs merged 1 commit into
masterfrom
monitor-archiving-system
Aug 11, 2026
Merged

Delete archived clients and snapshots in one transaction#18
needs merged 1 commit into
masterfrom
monitor-archiving-system

Conversation

@needs

@needs needs commented Aug 11, 2026

Copy link
Copy Markdown
Owner

archiveBatch deleted 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 single prisma.$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 LastModified is still monotonic with id across all ~2900 objects in the bucket, so no object has been rewritten.

🤖 Generated with Claude Code

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]>
@needs
needs merged commit 0b44cf7 into master Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant