Skip to content

[FLINK-40628][python] Avoid gateway launch during embedded TTL initialization - #29155

Open
bowenli86 wants to merge 5 commits into
apache:masterfrom
bowenli86:dev/bowenli/codex/flink-40628-embedded-ttl
Open

[FLINK-40628][python] Avoid gateway launch during embedded TTL initialization#29155
bowenli86 wants to merge 5 commits into
apache:masterfrom
bowenli86:dev/bowenli/codex/flink-40628-embedded-ttl

Conversation

@bowenli86

@bowenli86 bowenli86 commented Sep 10, 2026

Copy link
Copy Markdown
Member

What is the purpose of the change

Fix FLINK-40628. Initializing TTL-enabled state in a Python thread-mode operator can request a Py4J gateway while constructing the default RocksDB cleanup strategy. Starting that subprocess from a multithreaded TaskManager can leave the task stuck in INITIALIZING.

Brief change log

  • Defer the default 30-day Duration until the public accessor is called. The embedded converter continues to use Java's existing default.
  • Preserve explicit durations and existing falsey-argument behavior.
  • Include the test-only calc-variant savepoint refresh from FLINK-40631 / PR #29156, with its upstream attribution, so the unrelated master table test can deserialize the current Variant type.
  • Add Python regression tests for gateway-free construction, pickle/protobuf round trips, and accessor compatibility, plus a RocksDB thread-mode regression that guards gateway access inside the worker and checks state updates across four cleanup policies.

Verifying this change

  • Azure build 78968 at current head 2932b88ed1ababb9abb6dd9bfd37a54ae00b90c1 passed all 13 jobs: compilation, Python, table, core, connectors, misc, tests, licensing, documentation, and all four E2E groups.
  • Python CI exercised both test_state_ttl_config.py and the checked-in EmbeddedDataStreamStreamTests.test_state_ttl_without_gateway. The previously failing CalcRestoreTest also passed with zero failures or errors after the fixture refresh. No tests are disabled or skipped by this change.
  • The local regression suite passed 5 tests and 11 subtests; Flake8, syntax, and diff checks passed.
  • Standalone execution of the exact TTL worker UDF in public Flink 2.3.0 / Pemja 0.5.7 / Python 3.11 / Java 17 with RocksDB failed before the TTL fix at the gateway guard and passed afterward with all four cases and eight expected outputs.

Does this pull request potentially affect one of the following parts:

  • Dependencies: no
  • Public API: no signature or annotation changes
  • Serializers: no format changes
  • Runtime per-record code paths: no
  • Deployment or recovery: Python operator state initialization; no checkpoint/savepoint format or behavior changes
  • S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes

Generated-by: Codex (GPT-6)

…lization

Keep the default RocksDB cleanup duration lazy and materialize it only when requested through the public accessor.

Generated-by: Codex (GPT-6)
@flinkbot

flinkbot commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@bowenli86
bowenli86 marked this pull request as ready for review September 10, 2026 22:41
…t after Variant type change

The Variant interface is Serializable without an explicit serialVersionUID,
so its auto-generated UID changes whenever its declared method set changes.
FLINK-40515 added a UUID accessor to the interface, which shifted the UID and
invalidated the checked-in calc-variant restore savepoint. CalcRestoreTest then
failed to restore it with InvalidClassException.

Regenerate the calc-variant savepoint against the current Variant. The compiled
plan is unchanged.

Generated-by: Claude Code (claude-opus-4-8)
(cherry picked from commit 7ee18e0)
@bowenli86

Copy link
Copy Markdown
Member Author

@flinkbot run azure

…ixture

Remove the separately tracked FLINK-40631 fixture correction from this PR while preserving the existing TTL changes and commit history.

Generated-by: Codex (GPT-6)
…or CI

Restore the upstream-generated fixture from commit 7ee18e0 (apache#29156) so the unrelated CalcRestoreTest also passes. This restores the source tree tested successfully by Azure build 78961 while preserving the existing PR commits.

Generated-by: Codex (GPT-6)
@bowenli86

Copy link
Copy Markdown
Member Author

@flinkbot run azure

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

@bowenli86 Good catch! Thanks for this fix.

Do you think it makes sense to add some centralized guard (raise some meaningful error messages to tell users to use pemja.findClass if they want to call Java from Python in thread mode) for embedded workers. Users can accidentally‌ call Py4J and potentially fall through to launch_gateway().

Besides, I saw that we have included changes of FLINK-40631 in this PR. Are there any special reasons to do so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants