Skip to content

fix(pyamber, 1.1): make ExecutorManager module names process-globally unique#4868

Merged
Yicong-Huang merged 1 commit into
apache:release/v1.1.0-incubatingfrom
Yicong-Huang:backport/4717-release-v1.1
May 3, 2026
Merged

fix(pyamber, 1.1): make ExecutorManager module names process-globally unique#4868
Yicong-Huang merged 1 commit into
apache:release/v1.1.0-incubatingfrom
Yicong-Huang:backport/4717-release-v1.1

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang commented May 3, 2026

What changes were proposed in this PR?

Backport #4717 (commit 6ae0c46312ca744b4f761c88f1ec172ba0d41d13 on main) onto release/v1.1.0-incubating.

ExecutorManager previously used a per-instance executor_version counter for the udf-vN tmp module name, so a fresh ExecutorManager always produced udf-v1 and collided with whatever udf-v1 was already cached in sys.modules from an earlier instance. The post-collision clear() + importlib.reload() recovery silently returned a stale class on Python 3.11. Lift the counter to a class-level itertools.count(1) so module names are unique across every instance in the same Python process; the recovery branch becomes unreachable and is removed.

This unblocks #4636 (and any future release/*-labelled PR): the auto-backport leg's core/runnables/test_main_loop.py::test_batch_dp_thread_can_process_batch was failing on the 3.11 matrix entry against this branch with AttributeError: 'TestOperator' object has no attribute 'count' (the stale-class symptom), and the failed test left a non-daemon main_loop_thread alive that prevented pytest from exiting — surfacing as a 30+ minute hang.

Any related issues, documentation, discussions?

Backports #4717. Original issue: #4705.

How was this PR tested?

Cherry-pick of an already-reviewed and merged commit. One conflict in test_executor_manager.py (release branch lacked the trailing TestUpdateExecutor test class that #4717 introduced); resolved by taking the incoming version verbatim. Local syntax + ruff format --check pass on both modified files. CI on this PR will exercise the change against the release branch's full Python matrix.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (claude-opus-4-7)

…ue (apache#4717)

Lift `ExecutorManager`'s tmp module-name counter from a per-instance
attribute to a process-wide `itertools.count(1)`. Generated module names
(`udf-vN`) are now unique across every instance in the same Python
process, so the `if module_name in sys.modules: clear()+reload()`
recovery branch (which silently returned a stale class on 3.11) is
unreachable and removed.

Production path is unchanged — a worker process holds exactly one
`ExecutorManager` and its counter was already monotonic across
reconfigures.

Closes apache#4705.

`sbt 'WorkflowExecutionService / Test / testOnly test_executor_manager
test_main_loop'` — 23/23 pass. The combined run that previously leaked
`TestOperator` from `test_executor_manager.py` into
`test_main_loop.py`'s fixtures is now clean.

`test_executor_manager.py` updated for the new semantics: assertions on
`executor_version == 0/1` and `operator_module_name == "udf-v1"` change
to relative-ordering checks since the counter's absolute starting value
depends on prior tests in the session.

Generated-by: Claude Code (Opus 4.7, 1M context)
@Yicong-Huang Yicong-Huang changed the title fix(pyamber): make ExecutorManager module names process-globally unique (backport #4717 to release/v1.1.0-incubating) fix(pyamber, 1.1): make ExecutorManager module names process-globally unique (backport #4717 to release/v1.1.0-incubating) May 3, 2026
@Yicong-Huang Yicong-Huang requested a review from bobbai00 May 3, 2026 17:57
@Yicong-Huang Yicong-Huang added the emergency Pull requests that need to be merged ASAP label May 3, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.50%. Comparing base (a244f2a) to head (f5bd347).

Additional details and impacted files
@@                       Coverage Diff                       @@
##             release/v1.1.0-incubating    #4868      +/-   ##
===============================================================
+ Coverage                        41.48%   41.50%   +0.01%     
  Complexity                        1984     1984              
===============================================================
  Files                              952      952              
  Lines                            33801    33796       -5     
  Branches                          3713     3713              
===============================================================
+ Hits                             14024    14026       +2     
+ Misses                           19011    19003       -8     
- Partials                           766      767       +1     
Flag Coverage Δ
amber 39.88% <ø> (+<0.01%) ⬆️
python 79.60% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Yicong-Huang Yicong-Huang changed the title fix(pyamber, 1.1): make ExecutorManager module names process-globally unique (backport #4717 to release/v1.1.0-incubating) fix(pyamber, 1.1): make ExecutorManager module names process-globally unique May 3, 2026
@Yicong-Huang Yicong-Huang merged commit 22f1d0f into apache:release/v1.1.0-incubating May 3, 2026
27 of 32 checks passed
@Yicong-Huang Yicong-Huang deleted the backport/4717-release-v1.1 branch May 3, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emergency Pull requests that need to be merged ASAP engine python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants