sangkyoonnam opened a new pull request, #29600: URL: https://github.com/apache/flink/pull/29600
## What is the purpose of the change With `python.state.cache-size` set to 0, a keyed state's pending `clear()` is dropped when the current key changes before the bundle commits, so switching back to that key shows the cleared value again. `RemoteKeyedStateBackend.set_current_key` only keeps the old internal state when the cache size is positive; otherwise it discards the object without committing it. See [FLINK-41102](https://issues.apache.org/jira/browse/FLINK-41102). ## Brief change log - When the state cache is disabled, `RemoteKeyedStateBackend.set_current_key` commits each state's current internal state before dropping it, so pending operations such as `clear()` reach the state backend. ## Verifying this change This change added tests and can be verified as follows: - `test_clear_state_before_key_switch_without_state_cache` in `ProcessDataStreamStreamingTests` sets the state cache size to 0, keeps the clear and the key switches in one bundle, updates and clears a `ValueState` and a `ListState` for key `a`, processes key `b`, and reads key `a` again. On `master` the last read returns `100` and `[100]`; it returns `None` and `[]` with the change. The test restores the parallelism and configuration it changes, since the environment is shared by the tests in the class. - `ProcessDataStreamStreamingTests` and `ProcessDataStreamBatchTests` pass locally (63 tests). ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no - The serializers: no - The runtime per-record code paths (performance sensitive): yes, process-mode key switching when `python.state.cache-size` is 0. - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no - The 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? - [X] Yes (please specify the tool below) AI was used for the implementation, the verification runs and this description. Generated-by: Claude Code 2.1.308 (Claude Opus 5.5) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
