Skip to content

[FLINK-40551][tests] Select the checkpoint to restore by content in FileMergingChannelStateITCase - #29161

Open
pedromazala wants to merge 1 commit into
apache:masterfrom
pedromazala:pedromazala/FLINK-40551
Open

[FLINK-40551][tests] Select the checkpoint to restore by content in FileMergingChannelStateITCase#29161
pedromazala wants to merge 1 commit into
apache:masterfrom
pedromazala:pedromazala/FLINK-40551

Conversation

@pedromazala

@pedromazala pedromazala commented Sep 11, 2026

Copy link
Copy Markdown

The test asserted that the checkpoint it restores from carries in-flight input
channel state for the slow mapper, but selected that checkpoint by waiting for
the second completed checkpoint that persisted any in-flight data anywhere in
the job. Which subtask's buffers land in a given checkpoint depends on where the
barriers are when it is triggered, so the count was a calibration rather than a
condition: instrumenting the scan shows checkpoint 1 persists ~295 KB of
in-flight data while carrying no input channel state for the mapper at all, and
only checkpoint 2 has it on this hardware.

Walk the completed checkpoint history instead and restore from the first
checkpoint whose metadata really contains file-merged input channel state for
the slow mapper. The lookup reports which checkpoints it inspected if the job
terminates first, and skips checkpoints cleaned up while being read. The
SegmentFileStateHandle and state size checks stay hard assertions on the
selected checkpoint, so a file merging regression still fails loudly instead of
timing out.

What is the purpose of the change

Reduce flakiness around FileMergingChannelStateITCase

Brief change log

  • Replace the checkpoint selection in testRestoreFileMergedChannelState: instead of CommonTestUtils.waitForCheckpointWithInflightBuffers(..., INITIAL_CHECKPOINTS_TO_WAIT), which accepts the latest completed checkpoint that persisted any in-flight data anywhere in the job, the test now restores from a checkpoint selected by content
  • Add waitForCheckpointWithSlowMapperChannelState, which walks the completed checkpoint history oldest-first and returns the first checkpoint whose metadata actually carries file-merged input channel state for the slow-word-mapper operator
  • Bound that lookup with a deadline (CHECKPOINT_LOOKUP_TIMEOUT, polled every CHECKPOINT_LOOKUP_INTERVAL_MS) and report the inspected checkpoint ids on timeout, rather than looping until the surefire timeout kills the fork
  • Fail fast with the job's own failure cause if the job reaches a globally terminal state before such a checkpoint completes
  • Skip checkpoints that are subsumed and cleaned up while their metadata is being read, instead of failing the test on the resulting IOException
  • Extract collectChannelStateDelegates (and the ChannelStateDelegates holder) so the new predicate and assertFileMergedChannelState share one traversal of the checkpoint metadata
  • Keep the assertions themselves unchanged — all channel state delegates are SegmentFileStateHandle, total state size is positive, and the slow mapper's input channel state is non-empty — so a file merging regression still fails loudly on the selected checkpoint instead of timing out
  • Drop the now-unused INITIAL_CHECKPOINTS_TO_WAIT constant. Test-only change confined to FileMergingChannelStateITCase; the 3-arg waitForCheckpointWithInflightBuffers overload stays in use by UnalignedCheckpointRescaleSameUpstreamITCase

Verifying this change

The test was executed 20 times to ensure the flakiness was over.

This change is a trivial rework / code cleanup without any test coverage.

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
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Opus 5 (1M context).

@pedromazala
pedromazala force-pushed the pedromazala/FLINK-40551 branch 2 times, most recently from 50926be to 6e8ff1a Compare September 11, 2026 13:48
@flinkbot

flinkbot commented Sep 11, 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

@pedromazala
pedromazala force-pushed the pedromazala/FLINK-40551 branch from 6e8ff1a to f120706 Compare September 11, 2026 13:56
@pedromazala
pedromazala marked this pull request as ready for review September 11, 2026 13:56
…ileMergingChannelStateITCase

The test asserted that the checkpoint it restores from carries in-flight input
channel state for the slow mapper, but selected that checkpoint by waiting for
the second completed checkpoint that persisted any in-flight data anywhere in
the job. Which subtask's buffers land in a given checkpoint depends on where the
barriers are when it is triggered, so the count was a calibration rather than a
condition: instrumenting the scan shows checkpoint 1 persists ~295 KB of
in-flight data while carrying no input channel state for the mapper at all, and
only checkpoint 2 has it on this hardware.

Walk the completed checkpoint history instead and restore from the first
checkpoint whose metadata really contains file-merged input channel state for
the slow mapper. The lookup reports which checkpoints it inspected if the job
terminates first, and skips checkpoints cleaned up while being read. The
SegmentFileStateHandle and state size checks stay hard assertions on the
selected checkpoint, so a file merging regression still fails loudly instead of
timing out.

Generated-by: Claude Opus 5 (1M context)
@pedromazala
pedromazala force-pushed the pedromazala/FLINK-40551 branch from f120706 to 26cc91b Compare September 11, 2026 15:54

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

Thank you for the contribution

Can you explain please what exactly you are fixing and why?

@snuyanzin

Copy link
Copy Markdown
Contributor

I'm asking since the FLINK-40551 was fixed by reverting original commit at
#29100

after that it was not fail

so why do we need to change anything else here?

final CheckpointMetadata metadata =
TestUtils.loadCheckpointMetadata(checkpoint.getExternalPath());
return !collectChannelStateDelegates(metadata).slowMapperInputChannelState.isEmpty();
} catch (IOException e) {

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.

This catches more than the subsumption race described by the comment.loadCheckpointMetadata also reports corrupt headers, unsupported versions, truncated input, and deserialization failures as IOException. Since this checkpoint was already added to inspectedCheckpoints, those failures are silently discarded and a later checkpoint can make the test pass. Could we suppress only the missing/cleaned-up checkpoint case and rethrow other metadata read failures?

JobID jobID, MiniCluster miniCluster) throws Exception {
final Set<Long> inspectedCheckpoints = new HashSet<>();
final AtomicReference<String> restorePath = new AtomicReference<>();
CommonTestUtils.waitUntilCondition(

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.

Could we give this lookup an explicit deadline and include inspectedCheckpoints in the timeout failure? The one-argument waitUntilCondition loops without a timeout, while failIfJobStoppedCheckpointing only fires after the job becomes terminal. If the job remains running and completed checkpoints never contain the slow mapper's channel state, this test can hang until the outer build timeout, which keeps the original diagnosability problem.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Sep 12, 2026
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