Stateaccepted
Discussion threadhttps://lists.apache.org/thread/qpztk0jdpcmhomszjx63l53xv26xnmwf
Vote threadhttps://lists.apache.org/thread/dfx7vdkq9mx7hn0g06spbcybw8jdrvrr
JIRA

FLINK-40156 - Getting issue details... STATUS

Release<Flink Version>

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

As noted in FLIP-577, AI data processing workloads (e.g., model inference, multimodal processing) are increasingly running on Flink with expensive GPU resources. Unstable checkpoints in these scenarios cause full-graph rollbacks that waste significant computational cost. This FLIP introduces Regional Checkpoint to isolate checkpoint progress at the Pipeline Region level, preventing localized failures from impacting the entire job.

We therefore propose Regional Checkpoint: when some Regions experience checkpoint failure or Region Failover, the framework generates a logically complete Completed Checkpoint by combining the historical state of the failed Regions with the current state of the healthy Regions — provided that state consistency constraints are satisfied. This improves checkpoint availability for high-parallelism jobs.

Goals

  1. Optimized complete-checkpoint workflow — Allow partial region task failures: generate a logically complete Completed Checkpoint whose checkpointId remains the current one, but where some SubTaskState entries reference state from a historical checkpoint.
  2. Regional Checkpoint consistency guarantees — When restoring from such a cross-Region combined Completed Checkpoint, all operator states, Coordinator states, and external commit semantics must remain consistent.

Non-Goals

  1. ALL_TO_ALL edges are not covered — Topologies containing keyBy / rebalance / hash / shuffle edges typically merge the entire graph into a single region, automatically falling back to the existing checkpoint logic.
  2. Batch jobs are not covered — Batch jobs do not support checkpoints and are therefore out of scope.
  3. Region partitioning rules are not modified — We fully reuse the existing logic in SchedulingPipelinedRegionComputeUtil.
  4. Savepoint semantics are not modified — Savepoints remain whole-graph snapshots that follow the legacy path, serving as a compatibility fallback for this feature.
  5. Region Failover logic is not modified — The consistency guarantees of Region Failover are preserved unchanged.

Public Interfaces

Configuration Options

New Regional Checkpoint configuration options are added to org.apache.flink.configuration.CheckpointingOptions:

Key

Type

Default

Description

execution.checkpointing.region.enabled

Boolean

false

Global switch for Regional Checkpoint.

execution.checkpointing.region.max-failure-ratio

Double

0.3

Maximum ratio of regions that may fail within a single checkpoint and still allow commit.

execution.checkpointing.region.max-consecutive-failures

Integer

2

Maximum number of consecutive checkpoints that may reference historical 

checkpoint state.

Metrics & REST API Changes

/jobs/{jobid}/checkpoints response changes

  1. CompletedSubtaskCheckpointStatistics: new field ref_checkpoint_id (default: empty) — indicates which historical checkpointId this subtask’s state references.
  2. TaskCheckpointStatistics: new field oldest_ref_checkpoint_id (default: empty) — the earliest referenced checkpointId across all subtask instances of this Task.
  3. CheckpointStatistics: new field oldest_ref_checkpoint_id (default: empty) — the earliest referenced checkpointId across all Tasks in this checkpoint.

/jobs/{jobid}/checkpoints/config response changes

  1. regional_checkpoint_enabled: bool, default false — whether Regional Checkpoint is enabled.
  2. regional_max_failure_ratio: double, default 0.3 — maximum allowed ratio of failed regions.
  3. regional_max_consecutive_failures: int, default 2 — maximum allowed consecutive regional checkpoints

New Metric

  1. regional_checkpoint_count: cumulative count of regional checkpoints completed.

Web UI Changes

  1. Checkpoint config page — display Regional Checkpoint configuration options in the options section.
  2. Checkpoint detail page — show which subtasks reference historical checkpoints, with corresponding statistics columns.

Checkpoint Cleaner Logic

Currently, the JobManager cleans up expired Completed Checkpoints based on execution.checkpointing.num-retained  (default: 1). Since Regional Checkpoint metadata may contain references to historical checkpoint state, the CheckpointCleaner cannot rely solely on execution.checkpointing.num-retained  to determine which checkpoints to delete.

When Regional Checkpoint is enabled, the effective retention set = the most recent N Completed Checkpoints + all historical checkpoints transitively referenced via ref_checkpoint_id. A checkpoint may only be cleaned when it is no longer referenced by any retained checkpoint.

OperatorCoordinator Interface Extension

Although OperatorCoordinator is annotated with @Internal, developers can still implement this interface for subtask state coordination. To support Regional Checkpoint, we add two new default methods:

@Internal
public interface OperatorCoordinator extends CheckpointListener, AutoCloseable {

    /**
     * Indicates whether this coordinator supports regional checkpoint mode,
     * where some subtasks may fail to acknowledge and their state falls back
     * to the previous successful checkpoint.
     *
     * <p>When true, the framework invokes
     * {@link #checkpointCoordinatorForRegionFallback} after all task responses
     * are collected, instead of aborting the checkpoint.  Follows the same
     * opt-in pattern as {@link #supportsBatchSnapshot()}.  Default: false.
     */
    default boolean supportsRegionCheckpoint() {
        return false;
    }

    /**
     * Produce a coordinator snapshot consistent with the final task-side view.
     *
     * <p>{@code fallbackSubtaskIds} encodes the outcome:
     * <ul>
     *   <li>Empty — global checkpoint; all subtasks are at {@code checkpointId}.
     *   <li>Non-empty — regional checkpoint; subtasks in the set are at
     *       {@code fallbackCheckpointId}, others at {@code checkpointId}.
     *       The coordinator must roll back any bookkeeping for the fallback
     *       subtasks (e.g. split assignments) so that the snapshot matches
     *       this mixed view.
     * </ul>
     *
     * <p>The framework calls this after all task responses are collected and
     * before persisting checkpoint metadata.  The produced bytes replace what
     * a normal {@link #checkpointCoordinator} call would have written.
     *
     * @param checkpointId         current checkpoint id
     * @param fallbackCheckpointId historical checkpoint for fallback subtasks
     * @param fallbackSubtaskIds   subtask indices that fell back (empty = global)
     * @param resultFuture         to be completed with serialized coordinator state
     */
    default void checkpointCoordinatorForRegionFallback(
            long checkpointId,
            long fallbackCheckpointId,
            Set<Integer> fallbackSubtaskIds,
            CompletableFuture<byte[]> resultFuture) throws Exception {
        throw new UnsupportedOperationException(
            "Override supportsRegionCheckpoint() and this method to enable.");
    }
}

CheckpointListener Interface Extension

In the current design, when a Regional Checkpoint completes, only healthy-region tasks receive notifyCheckpointComplete. However, the existing interface does not provide any information to distinguish whether the completed checkpoint is a global checkpoint (all tasks acknowledged) or a regional checkpoint (some tasks fall back to historical state). This distinction is important for advanced use cases such as exactly-once sinks that need to be aware of the checkpoint's completeness scope or local state cleanup.

To address this, we propose adding two new default notification methods:

public interface CheckpointListener {

    // --- existing (unchanged) ---
    void notifyCheckpointComplete(long checkpointId) throws Exception;

    // --- new ---

    /**
     * Notifies the listener that a checkpoint has completed, with context
     * about whether this is a global or regional checkpoint.
     *
     * <p>{@code regionalCheckpointInfo.isGlobalCheckpoint()} is true when
     * all tasks acknowledged; false when some subtasks fell back to
     * historical state.  Implementations that need to distinguish the two
     * cases can override this method.  Default delegates to
     * {@link #notifyCheckpointComplete(long)}.
     */
    default void notifyRegionalCheckpointComplete(
            long checkpointId,
            RegionalCheckpointInfo regionalCheckpointInfo) throws Exception {
        notifyCheckpointComplete(checkpointId);
    }

    /**
     * Notifies the listener that a regional checkpoint completed but
     * this task's region fell back to a historical checkpoint.  Sent
     * to tasks in failed regions so they can clean up stale local state
     * from the aborted attempt.
     *
     * <p>Default: no-op.
     *
     * @param checkpointId         the completed regional checkpoint id
     * @param fallbackCheckpointId the historical checkpoint this task
     *                             fell back to
     */
    default void notifyRegionalCheckpointFallback(
            long checkpointId,
            long fallbackCheckpointId) {
        // no-op for backward compatibility
    }
}

/**
 * Provides context about a regional checkpoint.  Empty fallback map
 * means a global checkpoint (all tasks at the current checkpointId).
 */
public class RegionalCheckpointInfo {
    private final Map<Long, Set<String>> fallbackCheckpointSubtasks;

    public boolean isGlobalCheckpoint() {
        return fallbackCheckpointSubtasks.isEmpty();
    }
}

 

Proposed Changes

Flink’s current Checkpoint mechanism requires all Tasks to successfully acknowledge before a checkpoint can be completed. If any Task fails its checkpoint, declineCheckpoint is triggered and the entire checkpoint aborts. To ensure that checkpoints can still proceed normally during Region Failover scenarios, we propose Regional Checkpoint. The main modifications are:

  1. Snapshot Collection — Completing a checkpoint no longer requires all Tasks to acknowledge successfully. The JM combines the last successful checkpoint state of Tasks in the Failed Region with the current checkpoint state of Tasks in Normal Regions to produce a new Completed Checkpoint.
  2. State Correction — For OperatorCoordinator state, state changes in the failed region during the current checkpoint are rolled back. Using SourceCoordinator as an example, we identify which subtasks use the older checkpoint and roll back the split assignment records for those subtasks, returning splits to the enumerator for future assignment.
  3. Checkpoint Store — The checkpoint metadata records the referenced checkpointId for each task in the failed region, ensuring the CheckpointCleaner does not delete referenced historical checkpoints. To prevent unbounded growth of referenced checkpoints, the engine uses the `max-consecutive-failures` configuration to determine when a global checkpoint should be forced.

Overall Checkpoint Modification Flow

Step 1: Task Snapshot Report

After the CheckpointCoordinator receives a decline message from the failed Map[0], it buffers the decline rather than immediately aborting the checkpoint. It waits until all task responses are collected, then determines whether to proceed with a regional checkpoint based on the failure pattern. Since Map[0] failed, all three tasks in Region 0 require additional state handling.

Step 2: State Recombination

For the three operators in the failed Region 0 (Source[0], Map[0], Sink[0]), we use the state from the last successful checkpoint (ckp99) and combine it with the ckp100 state from the three operators in Region 1 to produce a new checkpoint (denoted ckp100s).

Step 3: State Correction

FLIP-27 introduced the OperatorCoordinator interface, which allows developers to implement custom operators that coordinate behavior across different subtask instances, with checkpoint support on the JM side.

When some subtasks coordinated by an OperatorCoordinator experience Region Failover, the coordinator cannot simply choose either the latest checkpoint’s Coordinator state or the historical checkpoint’s Coordinator state. Since the task-side state is a combination of historical state from some Regions and current state from other Regions, the Coordinator must produce a state that is consistent with this mixed view.

Therefore, before the Regional Checkpoint completes, the framework invokes checkpointCoordinatorForRegionFallback, passing the current checkpointId, fallbackCheckpointId, and fallbackSubtaskIds to the Coordinator. The Coordinator must roll back or compensate for incremental Coordinator-side state changes of the fallback subtasks since fallbackCheckpointId, and serialize the corrected state into the final checkpoint metadata.

Step 4: Checkpoint Store

For the combined checkpoint, we need to record additional information at the metadata level to ensure the CheckpointCleaner does not accidentally delete referenced historical checkpoints.

We add a ref_checkpoint_id field to the operatorSubtaskStates for the failed Region 0’s SourceReader state, marking which checkpointId that SubTask references. The JM uses this marker to avoid deleting referenced checkpoints. To prevent checkpoint bloat, we use the `execution.checkpointing.region.max-consecutive-failures` configuration to limit the maximum number of consecutive regional checkpoints.

CheckpointCoordinator Logic Changes

  1. The CheckpointCoordinator determines that Region 0’s checkpoint failed based on the failed Task (Map[0]). Therefore, the state for the three operators in Region 0 automatically falls back to the last successful checkpoint (ckpId = 99), while operators in Region 1 use the current ckpId = 100 state. Together they form the combined ckpId = 100 checkpoint.
  2. For operators in Region 0 that implement the OperatorCoordinator interface (e.g., Source[0]), the checkpointCoordinatorForRegionFallback interface is invoked for partial state rollback, followed by checkpoint serialization.
  3. Since Region 0 experienced failover (or ack timeout) , all tasks in Region 0 receive `notifyRegionalCheckpointFallback` notifications. Only tasks in Region 1 receive `notifyRegionalCheckpointComplete` notifications, ensuring Sink[1] can commit normally.

 SourceCoordinator Logic Changes

SourceCoordinator is the runtime’s default source operator coordinator, responsible for assigning Splits to SourceReaders. It uses SplitAssignmentTracker to record the splits assigned to each subtask at each checkpoint, ensuring split assignment consistency when restoring from a cross-region combined checkpoint.

During the CompleteCheckpoint phase in the SourceCoordinator scenario, the following three parts are combined into the new checkpoint:

  1. Region 0’s checkpoint at ckpId = 99
  2. Region 1’s checkpoint at ckpId = 100
  3. SourceCoordinator’s checkpoint at ckpId = 100 (denoted as ckp100s)

From the SplitAssignmentTracker’s perspective: during ckp100, it had already assigned split s6 to reader 0. Since reader 0 experienced failover and could not complete ckp100, reader 0’s split state contains only s1 and s2. Meanwhile, from ckp100 onward, the tracker’s unassigned splits contain only s7 — meaning s6 would be lost in ckp100s.

Therefore, the SourceCoordinator’s state must be corrected to ensure consistency of the combined checkpoint.

State Correction

  1. SplitAssignmentTracker retains the assignment records for each checkpointId and persists them to state.
  2. When the CheckpointCoordinator discovers that Region 0’s Source[0] must use the previous ckp99, it notifies SourceCoordinator to roll back the state for subtaskId 0. The s6 record in SplitAssignmentTracker is discarded and returned to the SplitEnumerator via addSplitsBack, awaiting the next assignment cycle.

Other Logic Changes

JM Recovery Procedure

During the Regional Checkpoint completion phase, all operator state handles (including those from historical checkpoints) are physically referenced within a single metadata file. JM recovery only needs to read one checkpoint metadata file — no multi-file loading or reconciliation step is required.

A refCheckpointId  field is added to OperatorSubtaskState for use by the checkpoint cleaner.

// OperatorSubtaskState.java
private final long refCheckpointId; // 0 means no reference (current checkpoint)

Per-Region Timeout Handling

When a task neither acknowledges nor declines within the checkpoint timeout (e.g., network partition, GC pause):

  1. The checkpoint timeout fires for unacknowledged tasks.
  2. The unacknowledged task’s region is treated as failed — identical to the declineCheckpoint path.
  3. If the failure ratio is within max-failure-ratio, the Coordinator proceeds with Regional Checkpoint: fetch historical state for the timed-out region, combine with current state of healthy regions.
  4. This counts toward max-consecutive-failures.

No per-region timeout configuration is introduced; the standard execution.checkpointing.timeout applies uniformly.

Local Recovery Cleanup

When a Regional Checkpoint completes, tasks in failed regions may still hold stale local state. A new regional checkpoint notification method (notifyRegionalCheckpointComplete/Fallback) is introduced:


  • Healthy regions: callback notifyRegionalCheckpointComplete — local state promoted normally.
  • Failed regions: callback notifyRegionalCheckpointFallback — TaskLocalStateStore discards the failed checkpoint’s local state. Cleanup is deferred to the next checkpoint trigger.

Bounded Source (Finished Operators)

For bounded source jobs (FLIP-147: CheckpointsAfterTasksFinished), a regional checkpoint at job termination could skip notifyCheckpointComplete for finished operators in a failed region, leaving their side effects (e.g., Kafka transactions) uncommitted — this is data loss.

Solution: force a global checkpoint when the job is about to terminate. When all sources are exhausted (all records processed), the JM marks the next checkpoint as mandatory global, requiring all regions to acknowledge. If this global checkpoint fails, the job retries rather than terminating with a partial snapshot.

Compatibility, Deprecation, and Migration Plan

  1. Checkpoint Metadata — Only new reference fields are added to record which checkpointId a SubTaskState originates from. This is fully backward-compatible with historical state.
  2. Savepoint — Savepoints comply fully with their design semantics: state directories are independent and restorable, with no cross-checkpoint directory storage. Regardless of whether Regional Checkpoint is enabled, Savepoints can be restored normally.
  3. FLIP-27 Source — `SourceCoordinator` will implement `checkpointCoordinatorForRegionFallback()` as part of this FLIP, enabling split assignment rollback for regional checkpoints.
  4. FLIP-547 (Support checkpoint during recovery) — does not introduce cross-region state dependencies. No fundamental conflict with Regional Checkpoint — the two should be compatible.

Test Plan

  1. Unit Tests: Verify the Regional Checkpoint workflow, including state recombination, state correction, and cleaner logic.
  2. Integration Tests: Verify data consistency when restoring from a Regional Checkpoint.

Limitation

The following limitations apply to Regional Checkpoint. Users must evaluate whether their job topology and operator semantics satisfy these constraints before enabling the feature.

Embarrassingly Parallel Regions Only

Regional Checkpoint only applies to embarrassingly parallel regions — regions connected exclusively via POINTWISE edges. Topologies containing BLOCKING or HYBRID edges (e.g., keyBy, rebalance, hash, shuffle) typically merge the entire graph into a single region, where Regional Checkpoint has no effect and automatically falls back to the existing global checkpoint logic.

Operator State Safety Assumption

Regional Checkpoint mixes state from different logical time points across subtasks. This is the first feature in Flink to relax the globally-atomic checkpoint guarantee. As such, operator state must satisfy the following safety conditions:

  • Each region’s state must be a deterministic function of the data it consumed. eg. Kafka Offset
  • There must be no cross-subtask agreement — no invariant requiring all subtasks to agree on a value (e.g., a recovery counter, an epoch tracker).
  • There must be no cross-element temporal invariant — no invariant requiring state entries from different subtasks to originate from the same logical time.

Operators with self-contained, per-partition state entries (e.g., Kafka offsets, file split positions) satisfy these conditions. Operators that maintain globally-coordinated counters, epoch markers, or cross-subtask consistency checks do not satisfy them and should not enable Regional Checkpoint.

This applies to both even-split and union operator state redistribution modes.

No Changelog State Backend Support

The Changelog State Backend has its own lifecycle management (materialization, periodic compaction). Supporting it with Regional Checkpoint would require changes to how changelog segments are referenced across checkpoints. This is not addressed in the current scope.

NO_CLAIM Mode Restrictions

When a job is restored from a Regional Checkpoint in NO_CLAIM mode (FLIP-193), the operator does not take ownership of state files. Users must wait for a successful global checkpoint before the original state files can be safely deleted. A regional checkpoint may still reference historical state via refCheckpointId.

FLINK-26803 introduced a shared channel state writer at the TaskManager level. If one subtask fails, the shared writer fails all subtasks on the same TM via failResultAndCloseStream(). This breaks Regional Checkpoint’s isolation guarantee — a failure from one region can cascade to healthy regions on the same TM. Until FLINK-26803 is consolidated into FLIP-306, Regional Checkpoint and FLINK-26803 are mutually exclusive.

Reference Chain Bounded by maxConsecutiveFailures

The refCheckpointId chain depth is bounded by execution.checkpointing.region.max-consecutive-failures. When the consecutive regional checkpoint count reaches this limit, the next checkpoint is forced to be global. This prevents unbounded growth of referenced historical checkpoints.

Future Work

FLIP-306 (Unified File Merging) Integration

FLIP-306 introduces a PhysicalFile–LogicalFile separation model with TM-level file ownership. The current FileMergingSnapshotManager notification lifecycle (checkpoint complete/abort/subsumed) does not account for “partially completed” semantics. For Regional Checkpoint, we need to introduce the new notification type (notify partially-completed) so that the merging manager knows: this checkpoint is complete but some segments belong to failed regions — keep the physical files that contain those segments alive until the referencing checkpoints are subsumed.

Ecosystem Validation

Individually validate CDC, Paimon, Fluss, and other ecosystem projects.

Implementation Plan

 Phase

Description

Depends on

Modules

1

Add configuration options + refCheckpointId field in OperatorSubtaskState

—

flink-core, flink-runtime

2

Extend OperatorCoordinator + CheckpointListener (all default methods, RegionalCheckpointInfo)

—

flink-core-api, flink-runtime

3

Modify CheckpointCoordinator: decline buffering, region failure judgment, state recombination, forced global checkpoint on max-consecutive-failures, CheckpointCleaner reference chain

1

flink-runtime

4

Implement SourceCoordinator region fallback: supportsRegionCheckpoint(), checkpointCoordinatorForRegionFallback(), SplitAssignmentTracker rollback

3

flink-runtime

5

Implement notification dispatch: notifyRegionalCheckpointComplete / notifyRegionalCheckpointFallback in CheckpointCoordinator + TaskLocalStateStore cleanup

3

flink-runtime

6

Per-Region Timeout Handling + Bounded Source forced global checkpoint on source exhaustion

3

flink-runtime

7

Metrics: regional_checkpoint_count

3

flink-runtime

8

REST API: new fields in /jobs/{jobid}/checkpoints and /config

7

flink-runtime

9

Web UI: display Regional Checkpoint config options + subtask historical reference info

8

flink-runtime-web

10

User documentation

1–9

docs/

  • Commit 2 is independent of 1 and 3, can run in parallel
  • Commits 4, 5, 6 are independent of each other, can run in parallel after 3
  • Commits 7 → 8 → 9 form a serial chain, but can run in parallel with 4–6


  • No labels