Fix deadlock in AsyncWrapper thread pool shutdown#38427
Fix deadlock in AsyncWrapper thread pool shutdown#38427shunping wants to merge 3 commits intoapache:masterfrom
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 an intermittent deadlock issue occurring during the teardown of 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
|
|
r: @dustin12 |
There was a problem hiding this comment.
Code Review
This pull request addresses a deadlock issue in AsyncWrapper.reset_state by moving the pool shutdown process outside of the global lock and adds a regression test to detect such hangs. A review comment correctly identifies that the pool.acquire() call remains inside the lock, which could still cause a deadlock if the pool is at capacity, and provides a suggestion to move it outside the lock scope.
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
During test execution or pipeline teardown, calling
reset_stateonAsyncWrapperintermittently hangs the pipeline indefinitely, leading to test runner timeouts (https://github.com/apache/beam/actions/runs/25590690572/job/75127752557?pr=38425).The traceback of timeout is shown below:
The deadlock occurs in the following order:
reset_stateacquiresAsyncWrapper._lockand callspool.shutdown(wait=True). It remains blocked waiting for active worker threads to finish while holding the lock.decrement_items_in_buffer, however, attempts to acquireAsyncWrapper._lockto decrement the buffer count. This leads to a deadlock.To fix it, we move the shutdown call outside of the lock scope, so while the main thread is waiting for worker threads to complete, it won't hold the lock.