Skip to content

Add retry in connecting manager in MultiProcessShared#38456

Merged
shunping merged 4 commits into
apache:masterfrom
shunping:fix-multi-process-shared
May 12, 2026
Merged

Add retry in connecting manager in MultiProcessShared#38456
shunping merged 4 commits into
apache:masterfrom
shunping:fix-multi-process-shared

Conversation

@shunping
Copy link
Copy Markdown
Collaborator

@shunping shunping commented May 12, 2026

Got another flaky test below (https://github.com/apache/beam/actions/runs/25705764624/job/75475412939 and https://github.com/apache/beam/actions/runs/25708527415/job/75483693419?pr=38455)

=================================== FAILURES ===================================
_ MultiProcessSharedSpawnProcessTest.test_unsafe_hard_delete_autoproxywrapper __
[gw1] linux -- Python 3.12.13 /runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/bin/python

self = <apache_beam.utils.multi_process_shared_test.MultiProcessSharedSpawnProcessTest testMethod=test_unsafe_hard_delete_autoproxywrapper>

    def test_unsafe_hard_delete_autoproxywrapper(self):
      shared1 = multi_process_shared.MultiProcessShared(
          Counter, tag='to_delete', always_proxy=True, spawn_process=True)
      shared2 = multi_process_shared.MultiProcessShared(
          Counter, tag='to_delete', always_proxy=True, spawn_process=True)
      counter3 = multi_process_shared.MultiProcessShared(
          Counter, tag='to_keep', always_proxy=True,
          spawn_process=True).acquire()
    
      counter1 = shared1.acquire()
      counter2 = shared2.acquire()
      self.assertEqual(counter1.increment(), 1)
>     self.assertEqual(counter2.increment(), 2)
E     AssertionError: 1 != 2

apache_beam/utils/multi_process_shared_test.py:333: AssertionError
----------------------------- Captured stderr call -----------------------------
INFO:root:Process 273400: Proxy serving to_keep at ('127.0.0.1', 44037)
INFO:root:Process 273459: Proxy serving to_delete at ('127.0.0.1', 33487)
INFO:root:Process 273507: Proxy serving to_delete at ('127.0.0.1', 44533)

This could happen when it fails to connect to the manager (a possibly remote proxy) at counter2 = shared2.acquire() due to some transient network issue. In the proposed fix, we add some retrying during making the connection.

@shunping shunping marked this pull request as ready for review May 12, 2026 03:28
@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 flaky tests in the MultiProcessShared utility by introducing a robust retry mechanism when connecting to the manager. By adding exponential backoff, the system can now gracefully recover from transient ConnectionError or EOFError exceptions, improving the reliability of multi-process shared resource management.

Highlights

  • Retry Mechanism: Implemented an exponential backoff retry strategy for manager connections in MultiProcessShared to handle transient network issues.
  • Test Coverage: Added a new test case to simulate and verify recovery from transient connection errors during proxy acquisition.
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.

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 introduces a retry mechanism with exponential backoff for manager connections in multi_process_shared.py, specifically handling ConnectionError and EOFError to improve resilience against transient failures. Corresponding tests were added to verify this behavior. Feedback suggests extracting the duplicated list of retryable exceptions into a variable to improve maintainability and ensure consistency.

Comment thread sdks/python/apache_beam/utils/multi_process_shared.py Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @tvalentyn for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@shunping shunping requested a review from tvalentyn May 12, 2026 18:51
@shunping shunping merged commit fa0eef9 into apache:master May 12, 2026
97 checks passed
@shunping shunping deleted the fix-multi-process-shared branch May 12, 2026 19:39
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