问题现象: Flink UI界面查看checkpoint的metrics发现一直没有做checkpoint,仔细排查发现有部分subtask的状态是finished。
下图是测试环境复现问题

问题原因: 仔细排查代码后发现source是消费kafka的数据,配置的并行度大于kafka的partition数,导致有部分subtask空闲,然后状态变为finished。后来查看了checkpoint过程的源码得以佐证。
在CheckpointCoordinator类的triggerCheckpoint方法中有如下代码段
// check if all tasks that we need to trigger are running.
// if not, abort the checkpoint
Execution[] executions = new Execution[tasksToTrigger.length];
for (int i = 0; i < tasksToTrigger.length; i++) {
Execution ee = tasksToTrigger[i].getCurrentExecutionAttempt();
if (ee == null) {
LOG.info("Checkpoint triggering task {} of job {} is not being executed at the moment. Aborting checkpoint.",
tasksToTrigger[i].getTaskNameWithSubtaskIndex(),
job

本文记录了一次Flink在UI中未进行checkpoint的情况,问题源于source并行度超过Kafka分区数,部分subtask进入finished状态。检查代码和CheckpointCoordinator的triggerCheckpoint方法确认,只有ExecutionState.RUNNING的subtask才会触发checkpoint。解决方案是确保source并发度不大于Kafka的partition数,以避免性能损失。此问题在Flink 1.5版本及更高版本已修复。
最低0.47元/天 解锁文章
2133

被折叠的 条评论
为什么被折叠?



