Skip to content

Fix race condition whith multiple rewrites to the same service#10180

Open
inlined wants to merge 7 commits intomainfrom
inlined.rca
Open

Fix race condition whith multiple rewrites to the same service#10180
inlined wants to merge 7 commits intomainfrom
inlined.rca

Conversation

@inlined
Copy link
Copy Markdown
Member

@inlined inlined commented Mar 25, 2026

EDIT: Turns out to not be the root cause of a previously linked bug. Still good to do, but not a high priority.

Currently if there are more than one rewrite to the same service then ensureLatestRevisionTagged gets the same service more than once. Adding this deduplication logic avoids simultaneous edits to the same service

@inlined inlined requested a review from bkendall March 25, 2026 21:41
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 resolves a potential race condition and improves efficiency in the setRewriteTags function. Previously, if multiple rewrites pointed to the same service, the system would attempt to fetch and process that service multiple times concurrently, leading to redundant calls and potential issues. The changes introduce a mechanism to deduplicate these service calls, ensuring that each unique service is processed only once, thereby preventing simultaneous edits and optimizing resource usage.

Highlights

  • Race Condition Fix: Addressed a race condition where ensureLatestRevisionTagged could be called multiple times for the same service when multiple rewrites target it, by implementing deduplication logic.
  • Performance Improvement: Optimized service fetching by ensuring run.getService is called only once per unique service, even if referenced by multiple rewrites.
  • Test Coverage: Introduced a new unit test to specifically verify the deduplication behavior for multiple rewrites to the same service.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 optimizes the setRewriteTags function in src/hosting/runTags.ts by introducing a deduplication mechanism. It ensures that run.getService is called only once for each unique service, even if multiple rewrites target the same service, thereby improving efficiency. A new test case in src/hosting/runTags.spec.ts has been added to validate this deduplication behavior. A review comment suggests refactoring the service promise collection to use a reduce function for a more functional and concise implementation.

if (rewrite.run.tag !== TODO_TAG_NAME) {
return null;
}
// Note: Deduplication is necessary to avoid race conditions when there are mutiple
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sentence feels unfinished.

@inlined inlined enabled auto-merge (squash) April 8, 2026 17:41
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