spoorthibasu opened a new pull request, #30164: URL: https://github.com/apache/flink/pull/30164
## What is the purpose of the change This implements [FLIP-619](https://cwiki.apache.org/confluence/spaces/FLINK/pages/462815651/FLIP-619+Store+large+operator+coordinator+state+outside+the+checkpoint+metadata). Currently, operator coordinator state is always stored inline in the checkpoint `_metadata` file, so with large enumerator state the JobManager keeps a copy for every retained checkpoint. With `execution.checkpointing.coordinator-state-in-file.enabled` (default `false`) and file system checkpoint storage, the state of coordinators that support it, including those of all FLIP-27 sources, goes to its own file unless it is empty or below an inline threshold, and the metadata keeps only the handle. ## Brief change log One commit per item, in order. The commit messages have the details. - Compose the coordinator reset on a future of the state - Fail the job when restoring a coordinator throws an error - Hold operator coordinator state as a `StreamStateHandle` - Restore operator coordinator state from its own file - Pass restores from a file through the coordinator holder - Hand coordinator state in its own file to its coordinator - Wait for the previous reset before reading the state - Add checkpoint metadata version 7 - Copy the coordinator state file on rewrite (State Processor API) - Store large operator coordinator state in its own file - Add integration tests for coordinator state in its own file - Add a migration test for source coordinator state - Document coordinator state stored in its own file Notes for reviewers: - Differences from the FLIP: a failure of a restore from a file is held until the coordinator is started, because at the first restore of the default scheduler the coordinator is initialized before the JobMaster has started, and until then its main thread executor discards tasks. Without `execution.checkpointing.coordinator-state-inline-threshold`, the code compares the size with the storage's threshold itself, so state of exactly that size goes to a file whatever the write buffer size. Before any state is restored, every coordinator is checked to be able to restore it, and a read checks the recorded size when it is known. A reset from a file waits for the previous one, at most 60 s, so that the JobManager does not hold both copies. - As the FLIP proposes, the files are written just before `_metadata`, on the thread that holds the `CheckpointCoordinator` lock. Writing 100 MB took a median of 28 ms on local disk and 722 ms on a local MinIO. With the option off, the same bytes go into `_metadata`, and with HA into the HA store, under the same lock. - FLIP-600 (#28963) also adds metadata version 7. Whichever of the two is merged second takes version 8 and adapts to the other. ## Verifying this change This change added tests and can be verified as follows: - Unit tests, including an `OperatorState` and a `CheckpointCoordinatorConfiguration` serialized by Flink 2.3.0. - `CoordinatorStateInFileITCase`, `CoordinatorStateInFileHaRecoveryITCase`, `CoordinatorStateMigrationITCase` and `SavepointWriterCoordinatorStateITCase` cover restores from savepoints and retained checkpoints, failovers with either scheduler, an adaptive rescale, ZooKeeper HA, savepoints of earlier Flink versions and the State Processor API. - In a MiniCluster with 30 MB of enumerator state and three retained checkpoints, the used heap after a full GC is 153 MiB with the option off and 65 MiB with it on. - Flink 2.3.0 deserializes a Java-serialized `OperatorState` from this change with inline coordinator state, and fails with a `ClassCastException` on one with the state in a file, as the release note describes. - [CI](https://github.com/spoorthibasu/flink/actions/runs/45929386315) and the [nightly workflow](https://github.com/spoorthibasu/flink/actions/runs/45929433943) pass on my fork. ## 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)`: yes, two new options in `CheckpointingOptions`, as described in FLIP-619 - The serializers: yes, checkpoint metadata version 7, the type of the coordinator state field of `OperatorState` (Java-serialized in HA entries), and two new fields of `CheckpointCoordinatorConfiguration` (Java-serialized with the job graph) - The runtime per-record code paths (performance sensitive): no - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes, checkpointing and JobManager restore. Apart from logging the option's state, logging a reset failure that was dropped before, and failing the job on an error while a coordinator is restored, behavior changes only when the option is enabled or a checkpoint taken with it is restored, read or disposed. - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? yes - If yes, how is the feature documented? docs and JavaDocs; release note on FLINK-41627 --- ##### Was generative AI tooling used to co-author this PR? - [ ] Yes (please specify the tool below) -- 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]
