Skip to content

Conversation

@ja573
Copy link
Member

@ja573 ja573 commented Dec 11, 2025

Resolve a race condition in WorkRelation::create() where concurrent insertions could compute the same relation_ordinal for inverse relations, triggering duplicate key violations on work_relation_ordinal_type_uniq.

The fix includes:

  • Moving max(relation_ordinal) selection fully inside the transaction
  • Introducing a pg_advisory_xact_lock keyed on (related_work_id, inverse relation type) to serialise ordinal assignment for each work/type pair

@ja573 ja573 requested a review from rhigman December 11, 2025 13:15
@ja573 ja573 merged commit 54279b7 into launch/v1.0.0 Dec 12, 2025
6 of 7 checks passed
@ja573 ja573 deleted the fix_work_relation_ordinal_race branch December 12, 2025 10:36
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.

3 participants