Skip to content

[EventEngine] Fix Python reconnect issues: use iomgr backup poller when EE is disabled#39894

Closed
sergiitk wants to merge 5 commits intogrpc:masterfrom
sergiitk:python-fix-reconnect
Closed

[EventEngine] Fix Python reconnect issues: use iomgr backup poller when EE is disabled#39894
sergiitk wants to merge 5 commits intogrpc:masterfrom
sergiitk:python-fix-reconnect

Conversation

@sergiitk
Copy link
Copy Markdown
Member

@sergiitk sergiitk commented Jun 17, 2025

Fix the issue with gRPC Python Client not recovering in certain situations: #38290, #39113, #39631.


This PR:

  • Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
  • Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via GRPC_PLATFORM_SUPPORTS_POSIX_POLLING due to currently unresolved fork issue.

Unlike #39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

@sergiitk sergiitk self-assigned this Jun 17, 2025
@sergiitk sergiitk added the release notes: yes Indicates if PR needs to be in release notes label Jun 17, 2025
@sergiitk sergiitk force-pushed the python-fix-reconnect branch from d18e518 to 0343576 Compare June 17, 2025 08:47
@sergiitk sergiitk force-pushed the python-fix-reconnect branch from c86618f to 17d1c95 Compare June 17, 2025 21:21
@sergiitk sergiitk force-pushed the python-fix-reconnect branch from 17d1c95 to 5f70540 Compare June 17, 2025 22:04
@sergiitk sergiitk changed the title [Python] Fix the reconnect test [EE] Fix Python reconnect issues by using iomgr backup poler when EE is disabled Jun 17, 2025
@sergiitk sergiitk changed the title [EE] Fix Python reconnect issues by using iomgr backup poler when EE is disabled [EE] Fix Python reconnect issues: use iomgr backup poller when EE is disabled Jun 17, 2025
@sergiitk sergiitk changed the title [EE] Fix Python reconnect issues: use iomgr backup poller when EE is disabled [EventEngine] Fix Python reconnect issues: use iomgr backup poller when EE is disabled Jun 17, 2025
@sergiitk sergiitk force-pushed the python-fix-reconnect branch 2 times, most recently from 2365111 to e806e6e Compare June 18, 2025 03:49
@sergiitk sergiitk force-pushed the python-fix-reconnect branch from e806e6e to d0fc3be Compare June 18, 2025 03:50
@sergiitk sergiitk marked this pull request as ready for review June 18, 2025 04:53
@sergiitk sergiitk requested a review from markdroth as a code owner June 18, 2025 04:53
Copy link
Copy Markdown
Contributor

@sreenithi sreenithi left a comment

Choose a reason for hiding this comment

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

LGTM, great work! Thanks for working on this!

static bool g_backup_polling_disabled;

void grpc_client_channel_global_init_backup_polling() {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
Copy link
Copy Markdown
Member

@drfloob drfloob Jun 18, 2025

Choose a reason for hiding this comment

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

I suspect you'll want to use the GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER macro instead. This change will otherwise make no difference on, say, Linux.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@eugeneo recommended it with the comment

I think Python backup poller woes would be alleviated if there was a check "and poller is not disabled" here:

g_backup_polling_disabled = grpc_core::IsEventEngineClientEnabled() &&

This should retain the original behavior for Python and iOS.

From what I checked, GRPC_PLATFORM_SUPPORTS_POSIX_POLLING will always be false when GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER is defined:

#if defined(GRPC_POSIX_SOCKET_TCP) && \
!defined(GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER)
#define GRPC_PLATFORM_SUPPORTS_POSIX_POLLING true
#else
#define GRPC_PLATFORM_SUPPORTS_POSIX_POLLING false
#endif

Please let me know what you think, I'm fine either way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some C++ knowledge you may be missing: That #define will only hold for that translation unit (i.e, it only applies to that cc file). The backup poller code will never see a #define made in posix_engine.cc, it's intended to be internal.

Copy link
Copy Markdown
Member Author

@sergiitk sergiitk Jun 18, 2025

Choose a reason for hiding this comment

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

Some C++ knowledge you may be missing

Most of it is missing, haha. I do cpp very occasionally. I guess I'll be changing now.

The backup poller code will never see a #define made in posix_engine.cc, it's intended to be internal.

@eugeneo - curious what was you reasoning to use GRPC_PLATFORM_SUPPORTS_POSIX_POLLING then

@sergiitk
Copy link
Copy Markdown
Member Author

Internal ref: b/420745567

sreenithi pushed a commit to sreenithi/grpc that referenced this pull request Jun 23, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
sreenithi pushed a commit to sreenithi/grpc that referenced this pull request Jun 23, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
sreenithi pushed a commit to sreenithi/grpc that referenced this pull request Jun 23, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
sreenithi pushed a commit to sreenithi/grpc that referenced this pull request Jun 23, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
yashykt pushed a commit that referenced this pull request Jun 23, 2025
…sues: use iomgr backup poller when EE is disabled (v1.73.x backport) (#39950)

Backport of #39894 to v1.73.x.
---
Fix the issue with gRPC Python Client not recovering in certain
situations: #38290, #39113, #39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support
that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it
falls back to the backup poller. Note that currently Python disables
POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to
currently unresolved fork issue.

Unlike #39131, this change is meant to be tested and merged to master,
and then backported to past branches with broken python client reconnect
logic.

However, once Event Engine fork support is fixed, Python will switch to
it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds.
After that, the backup poller should not be needed for Python. With the
updated test, the case with python relying on the backup poller is
covered, and we should be able to detect issues with Python having to
rely on in after switching to EE.

Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
@sergiitk sergiitk deleted the python-fix-reconnect branch June 23, 2025 18:15
anniefrchz pushed a commit to anniefrchz/grpc that referenced this pull request Jun 25, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
sergiitk added a commit that referenced this pull request Jun 26, 2025
…sues: use iomgr backup poller when EE is disabled (v1.72.x backport) (#39949)

Backport of #39894 to v1.72.x.
---
Fix the issue with gRPC Python Client not recovering in certain
situations: #38290, #39113, #39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support
that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it
falls back to the backup poller. Note that currently Python disables
POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to
currently unresolved fork issue.

Unlike #39131, this change is meant to be tested and merged to master,
and then backported to past branches with broken python client reconnect
logic.

However, once Event Engine fork support is fixed, Python will switch to
it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds.
After that, the backup poller should not be needed for Python. With the
updated test, the case with python relying on the backup poller is
covered, and we should be able to detect issues with Python having to
rely on in after switching to EE.

Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
sergiitk added a commit that referenced this pull request Jun 26, 2025
…sues: use iomgr backup poller when EE is disabled (#39948)

Backport of #39894 to v1.71.x.
---
Fix the issue with gRPC Python Client not recovering in certain
situations: #38290, #39113, #39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support
that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it
falls back to the backup poller. Note that currently Python disables
POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to
currently unresolved fork issue.

Unlike #39131, this change is meant to be tested and merged to master,
and then backported to past branches with broken python client reconnect
logic.

However, once Event Engine fork support is fixed, Python will switch to
it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds.
After that, the backup poller should not be needed for Python. With the
updated test, the case with python relying on the backup poller is
covered, and we should be able to detect issues with Python having to
rely on in after switching to EE.

Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
sergiitk added a commit to sergiitk/grpc that referenced this pull request Jun 26, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
paulosjca pushed a commit to paulosjca/grpc that referenced this pull request Aug 23, 2025
…en EE is disabled (grpc#39894)

Fix the issue with gRPC Python Client not recovering in certain situations: grpc#38290, grpc#39113, grpc#39631.

---

This PR:
- Keeps iomgr backup poller enabled on platforms that do not support that have EventEngine / POSIX poller disabled.
- Fixes and hardens Python's reconnect_test.

This fixes issues with Python Client recovery in certain cases when it falls back to the backup poller. Note that currently Python disables POSIX poller manually via `GRPC_PLATFORM_SUPPORTS_POSIX_POLLING` due to currently unresolved fork issue.

Unlike grpc#39131, this change is meant to be tested and merged to master, and then backported to past branches with broken python client reconnect logic.

However, once Event Engine fork support is fixed, Python will switch to it by removing `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` from all builds. After that, the backup poller should not be needed for Python. With the updated test, the case with python relying on the backup poller is covered, and we should be able to detect issues with Python having to rely on in after switching to EE.

Closes grpc#39894

COPYBARA_INTEGRATE_REVIEW=grpc#39894 from sergiitk:python-fix-reconnect 239b330
PiperOrigin-RevId: 773549056
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.

5 participants