Skip to content

Fix Dataflow legacy worker abort loop thread death issue - #38894

Merged
scwhittle merged 1 commit into
apache:masterfrom
damccorm:fix/dataflow-worker-abort-loop
Jun 11, 2026
Merged

Fix Dataflow legacy worker abort loop thread death issue#38894
scwhittle merged 1 commit into
apache:masterfrom
damccorm:fix/dataflow-worker-abort-loop

Conversation

@damccorm

@damccorm damccorm commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Previously, when the service asked the worker to abort, it threw ReadLoopAbortedException, which extends InterruptedException. MapTaskExecutor caught this and, in an attempt to preserve the interrupted status, set the interrupted bit on the thread. However, since this was a logical abort and not a real thread interrupt, setting the interrupted bit caused subsequent operations on the thread (like the backoff sleep in DataflowBatchWorkerHarness) to immediately fail with InterruptedException, leading to all worker threads dying and the harness hanging.

This fix changes the interruption handling in MapTaskExecutor to not set the interrupted bit if it is just rethrowing the InterruptedException. Since we are throwing the exception, we can rely on the caller to set the bit if they swallow it and need to preserve it.

This was introduced in #36631

@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 addresses a critical issue where logical abort signals were incorrectly interpreted as thread interrupts, causing worker threads to fail prematurely and hang the harness. By adjusting the exception hierarchy and improving the failure handling in the worker harness, the system now correctly manages abort signals and ensures proper process termination upon worker thread death.

Highlights

  • Exception Hierarchy Refactoring: Changed ReadLoopAbortedException to extend InterruptedIOException instead of InterruptedException to prevent accidental thread interruption status triggers.
  • Worker Harness Robustness: Added a RuntimeException in DataflowBatchWorkerHarness to ensure the JVM exits with a non-zero code if all worker threads terminate unexpectedly.
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 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 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 .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 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

  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.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces changes to worker termination and exception handling. Specifically, it throws a RuntimeException when processWork completes in DataflowBatchWorkerHarness and changes ReadLoopAbortedException to extend InterruptedIOException instead of InterruptedException. Feedback highlights that throwing an unconditional exception upon worker exit could disrupt graceful shutdowns, and changing the exception hierarchy may cause issues with existing catch blocks that expect InterruptedException.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@damccorm
damccorm marked this pull request as draft June 10, 2026 14:52
Previously, when the service asked the worker to abort, it threw
ReadLoopAbortedException, which extends InterruptedException.
MapTaskExecutor caught this and, in an attempt to preserve the
interrupted status, set the interrupted bit on the thread.
However, since this was a logical abort and not a real thread interrupt,
setting the interrupted bit caused subsequent operations on the thread
(like the backoff sleep in DataflowBatchWorkerHarness) to immediately
fail with InterruptedException, leading to all worker threads dying
and the harness hanging.

This fix changes the interruption handling in MapTaskExecutor to not
set the interrupted bit if it is just rethrowing the InterruptedException.
Since we are throwing the exception, we can rely on the caller to
set the bit if they swallow it and need to preserve it.

Ref: b/512366613
@damccorm
damccorm force-pushed the fix/dataflow-worker-abort-loop branch from cf3538f to 91af38b Compare June 10, 2026 15:21
@damccorm

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request removes the block that re-interrupts the current thread when an InterruptedException is caught inside MapTaskExecutor.java. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@damccorm
damccorm marked this pull request as ready for review June 10, 2026 17:23
@damccorm

Copy link
Copy Markdown
Contributor Author

R: @scwhittle

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request removes the logic that re-interrupts the current thread when an InterruptedException is caught in MapTaskExecutor.java. There are no review comments to evaluate, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@scwhittle scwhittle left a comment

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.

I think we might want to make some of the other suggestions to harden against the threads exiting and leaving the worker idle but those can be separate follow ups as this is the root-cause.

@scwhittle
scwhittle merged commit 1cf3545 into apache:master Jun 11, 2026
25 of 27 checks passed
@damccorm
damccorm deleted the fix/dataflow-worker-abort-loop branch June 12, 2026 13:50
ash6898 pushed a commit to ash6898/beam that referenced this pull request Jun 29, 2026
Previously, when the service asked the worker to abort, it threw
ReadLoopAbortedException, which extends InterruptedException.
MapTaskExecutor caught this and, in an attempt to preserve the
interrupted status, set the interrupted bit on the thread.
However, since this was a logical abort and not a real thread interrupt,
setting the interrupted bit caused subsequent operations on the thread
(like the backoff sleep in DataflowBatchWorkerHarness) to immediately
fail with InterruptedException, leading to all worker threads dying
and the harness hanging.

This fix changes the interruption handling in MapTaskExecutor to not
set the interrupted bit if it is just rethrowing the InterruptedException.
Since we are throwing the exception, we can rely on the caller to
set the bit if they swallow it and need to preserve it.

Ref: b/512366613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants