Fix race condition in UserPipelineTracker.clear() and various problems#38537
Conversation
Summary of ChangesHello, 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 addresses a race condition in the UserPipelineTracker class that frequently caused flaky tests. By implementing an RLock and ensuring that all read/write operations and iterations on internal state are protected, the changes prevent dictionary mutation errors during concurrent access. A new test case was also included to validate the fix by explicitly orchestrating a race condition. Highlights
New Features🧠 You can now enable Memory (public preview) 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 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 the 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 counterproductive. 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
|
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
There was a problem hiding this comment.
Code Review
This pull request introduces thread safety to the UserPipelineTracker class by adding an RLock and wrapping critical dictionary operations in with self._lock blocks. It also includes a new test case to verify the fix for a potential race condition in the clear() method. My feedback highlights that the type hints for _derived_pipelines and _pid_to_pipelines are incomplete and should be updated, and suggests refactoring the clear() method to ensure atomicity and prevent potential resource leaks during concurrent operations.
There was a problem hiding this comment.
Code Review
This pull request introduces thread safety to the UserPipelineTracker class by implementing a reentrant lock (RLock) across its core methods. Key changes include wrapping dictionary access and mutations within lock blocks, refining the clear method to perform I/O operations outside the lock, and adding a regression test to verify thread safety during concurrent mutations. Review feedback correctly identifies a logic error in the evict method that causes unintended tree-wide deletions when a derived pipeline is targeted, as well as a resource leak where pipelines are not removed from the internal PID tracker. Additionally, several instances of a typo in the internal method name _memoize_pipieline were flagged for correction.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
42fb409 to
5a01c93
Compare
…test_instrument_example_pipeline_to_read_cache.
|
assign set of reviewers |
|
Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
The PR mainly fixes the race condition that causes the following flaky test by adding lock on the operations.
Additionally, it fixes a resource leak for
UserPipelineTracker.evictwhere evicted pipelines were not removed from_pid_to_pipelines.Finally, it fixes a typo:
_memoize_pipieline->_memoize_pipeline.