Skip to content

Always mark the instruction as cleaned up in the GRPC data channel when processing an instruction fails. - #36367

Merged
tvalentyn merged 4 commits into
apache:masterfrom
tvalentyn:bundle_processor_cleanup
Oct 16, 2025
Merged

Always mark the instruction as cleaned up in the GRPC data channel when processing an instruction fails.#36367
tvalentyn merged 4 commits into
apache:masterfrom
tvalentyn:bundle_processor_cleanup

Conversation

@tvalentyn

@tvalentyn tvalentyn commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

fixes: #31571

This PR resolves a deadlock in the Python SDK harness that happens when a flaky DoFn.setup() causes an instruction failure while creating a bundle processor, which creates stuckness in the data plane, when we try to populate the input queue for the failed instruction, while the queue never cleans up, thus preventing successful element ingestion for other all other instructions.

To fix, mark instruction as cleaned up in known GRPC data channels (that we cache), as we discard the instruction in bundle_processor_cache + add a few changes to ensure idempotentcy of the cleanup operations.

Before:

image

After:
image

@tvalentyn

Copy link
Copy Markdown
Contributor Author

R: @scwhittle

@github-actions

github-actions Bot commented Oct 3, 2025

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

@tvalentyn
tvalentyn marked this pull request as ready for review October 3, 2025 02:24

@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.

Is it possible to add a unit test that verifies that if processor creation throws an exception that we cleanup the channel?

Comment thread sdks/python/apache_beam/runners/worker/data_plane.py

def cleanup(self, instruction_id):
# type: (str) -> None
for channel in self._data_channel_cache.values():

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.

do we need to worry about thread-safety with concurrent creates?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in general, yes, it wouldn't hurt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

although we won't likely be hitting this race since we probably create all channels relatively early

Comment thread sdks/python/apache_beam/runners/worker/sdk_worker.py
@scwhittle

Copy link
Copy Markdown
Contributor

@tvalentyn friendly ping on comments so we can make release cut next week

@tvalentyn

Copy link
Copy Markdown
Contributor Author

Is it possible to add a unit test that verifies that if processor creation throws an exception that we cleanup the channel?

will take a look but possibly after a release cut if we want to merge this asap

@tvalentyn
tvalentyn force-pushed the bundle_processor_cleanup branch from cfcc81e to 714cad6 Compare October 15, 2025 21:18
@tvalentyn

Copy link
Copy Markdown
Contributor Author

Is it possible to add a unit test that verifies that if processor creation throws an exception that we cleanup the channel?

Added one.

@tvalentyn
tvalentyn force-pushed the bundle_processor_cleanup branch from 714cad6 to bf16250 Compare October 15, 2025 21:22
@tvalentyn
tvalentyn merged commit 581ec8b into apache:master Oct 16, 2025
113 of 118 checks passed
@tvalentyn
tvalentyn deleted the bundle_processor_cleanup branch October 16, 2025 17:10
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.

[Bug]: Python sdk data plane can become stuck on instructions that had an exception while calling BundleProcessor setup

2 participants