-
Notifications
You must be signed in to change notification settings - Fork 15
fix: remove mutexes around ownerinfo/rvinfo #111
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
Conversation
Summary of ChangesHello @runcom, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request streamlines the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request removes mutexes from the ownerinfo and rvinfo handlers. The removal in api/handlers/ownerinfo.go is correct, as the mutex was scoped per-request and thus ineffective. However, removing the shared mutex in api/handlers/rvinfo.go re-introduces a critical race condition that can lead to unhandled errors and 500 responses to clients. I've added a detailed comment explaining the issue and suggesting solutions. While the mutex in ownerinfo was ineffective, it's worth noting that both handlers share a similar check-then-act pattern vulnerable to race conditions, which would be best addressed at the database level for a scalable solution.
96ca580 to
43b7940
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request removes mutexes from the ownerinfo and rvinfo handlers, with the goal of relying on database constraints for ensuring atomicity. This is a positive change in direction. However, the implementation is incomplete as it leaves behind check-then-act patterns that were previously protected by the mutexes. Without the mutexes, these patterns introduce race conditions. My review focuses on identifying these race conditions and suggests removing the redundant pre-checks to make the create and update operations fully atomic.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly removes the ineffective local mutexes in the ownerinfo and rvinfo handlers and replaces the racy check-then-act logic with atomic database operations. This significantly improves the correctness and robustness of these endpoints under concurrent requests. The addition of tests for the new conflict and not-found behaviors is also a great improvement.
I've added a few comments regarding error handling for data validation. Currently, user data parsing errors are resulting in a 500 Internal Server Error, when a 400 Bad Request would be more appropriate. Addressing this would make the API more robust and user-friendly. Overall, this is a solid improvement.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is a great improvement. It removes the application-level mutexes around ownerinfo and rvinfo handling and instead relies on the database for concurrency control. This is a more robust solution that avoids race conditions, especially in multi-instance deployments. The changes correctly use atomic database operations and handle the resulting errors in the HTTP handlers. The addition of integration tests for this new behavior is also excellent. I have one suggestion to refactor some duplicated code in the database layer for better maintainability.
kgiusti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - one nit: could you add another testcase to trigger the new error types ErrInvalidOwnerInfo = errors.New("invalid ownerinfo data")
ErrInvalidRvInfo = errors.New("invalid rvinfo data")
4f630ab to
88d5aed
Compare
addressed with the latest revision |
djach7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
mmartinv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, just some nit.
As a side comment: I really don't like the OwnerInfo name/term as it's misleading and not present at the FIDO Specification. I would rename it to RVTO2Addr or similar
Created #118 to start the discussion there (AI made all the changes, so, let's discuss if it's what we want and decide what to do) thanks for the reviews folks! |
Signed-off-by: Antonio Murdaca <[email protected]>
Fix #11