fix: Skip obsolete message on collection foreign-key violation#495
Merged
Conversation
A collection can be deleted (by the wiper) while another worker is compiling releases into it or storing files for it. The concurrent transaction commits rows referencing the now-deleted collection, so the foreign key fails at COMMIT. This is a benign race, not a logic error: the message is obsolete, so skip it (like Collection.DoesNotExist), rather than shutting the worker down. Distinguish this case from other foreign-key violations (a package_data or data row still referenced), which continue to shut down, by the collection_id in the violated constraint name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYEutYV3RKbyi8Vd26QdxE
The compiled collection can be hard-deleted (by the wiper) while its
compiler_release/compiler_record messages are still queued. The
release_compiler and record_compiler callbacks fetched it with get(),
so a deleted collection raised Collection.DoesNotExist, which the
central errback logged as an error ("maybe caused by duplicate message")
and skipped.
This is a benign, expected race, not a duplicate message. Fetch with
filter().first() and treat a missing collection like an already-canceled
one (deleted_at): acknowledge the obsolete message and return, without
the misleading error.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WYEutYV3RKbyi8Vd26QdxE
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #495 +/- ##
==========================================
- Coverage 86.25% 82.69% -3.56%
==========================================
Files 24 26 +2
Lines 1397 1520 +123
==========================================
+ Hits 1205 1257 +52
- Misses 192 263 +71 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
A collection can be deleted (by the wiper) while another worker is
compiling releases into it or storing files for it. The concurrent
transaction commits rows referencing the now-deleted collection, so the
foreign key fails at COMMIT. This is a benign race, not a logic error:
the message is obsolete, so skip it (like Collection.DoesNotExist),
rather than shutting the worker down.
Distinguish this case from other foreign-key violations (a package_data
or data row still referenced), which continue to shut down, by the
collection_id in the violated constraint name.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01WYEutYV3RKbyi8Vd26QdxE