java是否有任何方法可以确保在Flink on job cancel with savepoint上通知所有检查点侦听器检查点完成?
我正在使用flink 1.9和REST API /jobs/:jobid/savepoints
触发保存点并取消作业(优雅地停止作业,以便稍后从保存点运行)
我在源代码中使用了两阶段提交函数,因此我的源代码实现了CheckpointedFunction
和CheckpointListener
接口。在snapshotState()
方法调用时,我将内部状态和notifyCheckpointComplete()
检查点状态快照到第三方系统
从源代码中可以看出,只有snapshotState()
部分在CheckpointCoordinator
中是同步的-
// send the messages to the tasks that trigger their checkpoint
for (Execution execution: executions) {
if (props.isSynchronous()) {
execution.triggerSynchronousSavepoint(checkpointID, timestamp, checkpointOptions, advanceToEndOfTime);
} else {
execution.triggerCheckpoint(checkpointID, timestamp, checkpointOptions);
}
}
检查点确认和完成通知在^{
也就是说,当savepoint
的cancel-job
设置为true
的savepoint
被触发时,在拍摄快照之后,一些任务管理器会在作业取消和执行notifyCheckpointComplete()
之前收到完成通知,而一些任务管理器则不会
问题是,是否有一种方法可以使用保存点取消作业,从而保证在作业取消之前所有任务管理器都会调用notifyCheckpointComplete()
,或者目前没有方法实现这一点
# 1 楼答案
使用带保存点的停止[1][2]难道不能解决问题吗
[1]https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/rest_api.html#jobs-jobid-stop [2] https://ci.apache.org/projects/flink/flink-docs-stable/ops/cli.html
# 2 楼答案
我已经有一段时间没看Flink 1.9了,所以请谨慎对待我的回答
我猜你的消息来源取消得太早了。因此
notifyCheckpointComplete
实际上被发送到所有任务,但是一些SourceFunction
已经退出run
,相应的任务被清理好吧,如果你在收到最后一个
notifyCheckpointComplete
之前忽略取消和中断,你所描述的应该是可能的