Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Recover from failure
  • Refresh job environment
    • Rescale or change job graph
    • Upgrade and state migration
  • Switch state backend
  • Import and export (FLIP-43 [7])
  • Fork job for blue/red deployment

While relatively, database uses backups [87] to:

  • Recover from accidental deletes
  • Refresh development environments
  • Migrate databases or switch storage engine [98]
  • Import and export data
  • Create database copies for testing, training and demonstrations

In Flink we have long supported cancel with savepoint, and recently in in FLIP-34 [10] we  we have implemented stop with savepoint, both could be mapping to automatically triggering a backup before killing/shutting down the database instance, and completely orthogonal with the fuzzy/sharp checkpoint process.

...

It also makes sense if user issues another cancel command for quick job termination when observing the stop process got stuck, similar to killing the database instance if don’t want to wait for the normal shutdown. And we should make sure the after-stop cancel command could take effect.

Implementation

After FLIP-34 we have introduced two different types for job stop:

TypeSource OPSTask StatusJob Status
SUSPEND

Checkpoint Barrier,

End Of Stream

FinishedFinished
TERMINATE

MAX_WATERMARK, Checkpoint Barrier,

End Of Stream

FinishedFinished

And we need below implementations to support performing a checkpoint when stopping job when retained checkpoint is configured:

  1. The Job Manager triggers a synchronous checkpoint at the source, that also indicates one of TERMINATE or SUSPEND
  2. Sources send a MAX_WATERMARK in case of TERMINATE, nothing is done in case of SUSPEND
  3. The Task Manager executes the checkpoint in a SYNCHRONOUS way, i.e. it blocks until the state is persisted successfully and the notifyCheckpointComplete() is executed.
  4. The Task Manager acknowledges the successful persistence of the state for the checkpoint
  5. The Job Manager sends the notification that the checkpoint is completed
  6. The Task Manger unblock the synchronous checkpoint execution.
  7. Finishing the job progress from the sources, i.e. they shut down and EOS message propagate through the job.
  8. The Job Manager waits until the job state goes to FINISHED before declaring the operation successful.

More details please refer to PR#8617Similar to the current implementation in PR#8617, will add text description.

Note that currently user controls the life cycle of the retained checkpoint files, and restoring from retained checkpoint reuses the “flink run -s” command thus calling CheckpointCoordinator.restoreSavepoint, so it’s totally fine to restore from a retained checkpoint for multiple times or jobs if only users don’t delete it.

...

FLIP-34 has introduced new required options for stop command including "-s" and "-d" [119], which actually changes user behavior since old command w/o such options cannot work any more.

...

  1. What’s the concept in Flink relative to database snapshots? Shall we introduce one?
    • It may share the checkpoint format and allow difference between backends, but should be in different concept (not checkpoint or backup as in database)
    • It should share the difference between database snapshot and backup [1210]
  2. TBC

References

[1] https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/cli.html

...

[6] https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/savepoints.html

[7] https://cwiki.apache.org/confluence/display/FLINK/FLIP-43%3A+Savepoint+Connector[8] https://www.sqlshack.com/backup-and-restore-or-recovery-strategies-for-sql-server-database

[98] https://github.com/facebook/mysql-5.6/wiki/Migrating-from-InnoDB-to-RocksDB

[109] https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=103090212[11] https://github.com/apache/flink/pull/8213/files

[1210] https://www.oracle.com/technetwork/database/availability/rman-fra-snapshot-322251.html

...