Skip to content

fix: Skip obsolete message on collection foreign-key violation#495

Merged
jpmckinney merged 2 commits into
mainfrom
claude/collection-fk-constraint-error-2v6502
Jul 7, 2026
Merged

fix: Skip obsolete message on collection foreign-key violation#495
jpmckinney merged 2 commits into
mainfrom
claude/collection-fk-constraint-error-2v6502

Conversation

@jpmckinney

Copy link
Copy Markdown
Member

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

claude added 2 commits July 5, 2026 11:27
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

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.69%. Comparing base (a3bd7b9) to head (c99011b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpmckinney jpmckinney merged commit 65d6b2c into main Jul 7, 2026
11 of 12 checks passed
@jpmckinney jpmckinney deleted the claude/collection-fk-constraint-error-2v6502 branch July 7, 2026 01:16
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.

2 participants