Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CV2-5419: rescue ActiveRecord::RecordNotUnique for relationship save #2071

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

melsawy
Copy link
Contributor

@melsawy melsawy commented Oct 7, 2024

Description

Sentry issue: Handle the database validation ActiveRecord::RecordNotUnique.

Added a unit test to cover rescue case but I could not reproduce the race condition using Thread.new

References: CV2-5419

How has this been tested?

Implemented automated tests.

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I considered secure coding practices when writing this code. Any security concerns are noted above.
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

@melsawy melsawy marked this pull request as ready for review October 8, 2024 05:24
Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, @melsawy . I noticed one (unrelated?) thing that I'm going to mention in the ticket.

r = Relationship.create_unless_exists(source.id, target.id, Relationship.confirmed_type)
end
assert_nil r
Relationship.any_instance.unstub(:save)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder that it's not needed to unstub explicitly anymore.

@melsawy melsawy requested a review from caiosba October 8, 2024 17:15
@melsawy melsawy merged commit b6c59c6 into develop Oct 9, 2024
11 checks passed
@melsawy melsawy deleted the CV2-5419-active-record-record-not-unique-pg branch October 9, 2024 02:14
DGaffney pushed a commit that referenced this pull request Oct 15, 2024
…2071)

* CV2-5419: rescue ActiveRecord::RecordNotUnique for relationship save

* CV2-5419: delete suggested relation before create confirmed one
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