Skip to content

[FLINK-39061][example] Roll back StateMachineExample to v1 State API#27936

Merged
gaborgsomogyi merged 1 commit into
apache:masterfrom
spuru9:FLINK-39061
Jun 25, 2026
Merged

[FLINK-39061][example] Roll back StateMachineExample to v1 State API#27936
gaborgsomogyi merged 1 commit into
apache:masterfrom
spuru9:FLINK-39061

Conversation

@spuru9

@spuru9 spuru9 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

StateMachineExample was inadvertently changed to use the State V2 async API
(state.v2.ValueState, enableAsyncState(), asyncValue(), asyncUpdate(), asyncClear()),
which requires the ForSt backend. ForSt is still under development and does not yet support
CANONICAL savepoints — triggering one causes an IllegalStateException that crashes the job.

This PR rolls the example back to the v1 synchronous State API, which is GA, works with all
standard backends, and supports all savepoint formats including CANONICAL.

Brief change log

  • Replace state.v2.ValueState / ValueStateDescriptor imports with the v1 equivalents
  • Remove .enableAsyncState() from the keyBy chain in StateMachineMapper
  • Rewrite flatMap to use synchronous currentState.value(), update(), and clear() instead of asyncValue().thenAccept(...), asyncUpdate(), and asyncClear()

Verifying this change

This change is manually verified.

  • Reproduction: Confirmed that the original implementation fails savepoints with java.lang.IllegalStateException: ForStStateBackend does not support CANONICAL
    savepoints when deployed via the K8s Operator.
  • Validation: Verified that rolling back to the State V1 API allows successful savepoints using production-ready backends (e.g., RocksDB).
  • Local Build: Passed ./mvnw compile -pl flink-examples/flink-examples-streaming.

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): no
  • 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

StateMachineExample was using the State V2 async API (enableAsyncState(),
asyncValue(), asyncUpdate(), asyncClear()), which requires the ForSt backend.
ForSt is still in development and does not support CANONICAL savepoints,
causing an IllegalStateException when one is triggered.

Roll back to the v1 synchronous State API, which works with all GA backends
and supports all savepoint formats.
@spuru9 spuru9 marked this pull request as ready for review April 15, 2026 17:31
@flinkbot

flinkbot commented Apr 15, 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

@spuru9

spuru9 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

@rmetzger Can you take a look.

@spuru9

spuru9 commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@seb-pereira @gaborgsomogyi Can you take a look as well, tagging as you participated in the JIRA as well.

@seb-pereira seb-pereira 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.

Thanks @spuru9. This change effectively reverts to the v1 State and resolves the issue with creating canonical savepoints.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label May 19, 2026
@spuru9

spuru9 commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

@gaborgsomogyi Can you help with the merge.

@spuru9

spuru9 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@gaborgsomogyi Is this good for merge?
Also it would need a backport to all 2.x right?

@gaborgsomogyi gaborgsomogyi merged commit 59b5196 into apache:master Jun 25, 2026
@spuru9

spuru9 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@gaborgsomogyi Should I create the backport?

@gaborgsomogyi

Copy link
Copy Markdown
Contributor

Yeah, thanks.

@gaborgsomogyi

Copy link
Copy Markdown
Contributor

Please ping me when there is a green run on them

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

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants