Source:
<code>private void takeSnapshotSync( Map<OperatorID, OperatorSnapshotFutures> operatorSnapshotsInProgress, CheckpointMetaData checkpointMetaData, CheckpointMetrics checkpointMetrics, CheckpointOptions checkpointOptions, OperatorChain<?, ?> operatorChain, Supplier<Boolean> isCanceled) throws Exception { long checkpointId = checkpointMetaData.getCheckpointId(); long started = System.nanoTime(); ChannelStateWriteResult channelStateWriteResult = checkpointOptions.getCheckpointType() == CHECKPOINT ? channelStateWriter.getWriteResult(checkpointId) : ChannelStateWriteResult.EMPTY; CheckpointStreamFactory storage = checkpointStorage.resolveCheckpointStorageLocation(checkpointId, checkpointOptions.getTargetLocation()); try { for (StreamOperatorWrapper<?, ?> operatorWrapper : operatorChain.getAllOperators(true)) { if (!operatorWrapper.isClosed()) { operatorSnapshotsInProgress.put( <START> operatorWrapper.getStreamOperator().getOperatorID(), <END> buildOperatorSnapshotFutures( checkpointMetaData, checkpointOptions, operatorChain, operatorWrapper.getStreamOperator(), isCanceled, channelStateWriteResult, storage)); } } } finally { checkpointStorage.clearCacheFor(checkpointId); } LOG.debug( "{} - finished synchronous part of checkpoint {}. Alignment duration: ms, snapshot duration ms", taskName, checkpointId, checkpointMetrics.getAlignmentDurationNanos() / 1_000_000, checkpointMetrics.getSyncDurationMillis()); checkpointMetrics.setSyncDurationMillis((System.nanoTime() - started) / 1_000_000); }</code><technical_language>ditto exception letting checkpoint coordinator know, this checkpoint declined. Otherwise, risking a situation this checkpoint complete, this operator participating in it? move this if check higher, top of checkpointState method</technical_language>

Target:
private boolean takeSnapshotSync( Map<OperatorID, OperatorSnapshotFutures> operatorSnapshotsInProgress, CheckpointMetaData checkpointMetaData, CheckpointMetrics checkpointMetrics, CheckpointOptions checkpointOptions, OperatorChain<?, ?> operatorChain, Supplier<Boolean> isCanceled) throws Exception { for (final StreamOperatorWrapper<?, ?> operatorWrapper : operatorChain.getAllOperators(true)) { if (operatorWrapper.isClosed()) { env.declineCheckpoint(checkpointMetaData.getCheckpointId(), new CheckpointException("Task Name" + taskName, CheckpointFailureReason.CHECKPOINT_DECLINED_TASK_CLOSING)); return false; } } long checkpointId = checkpointMetaData.getCheckpointId(); long started = System.nanoTime(); ChannelStateWriteResult channelStateWriteResult = checkpointOptions.getCheckpointType() == CHECKPOINT ? channelStateWriter.getWriteResult(checkpointId) : ChannelStateWriteResult.EMPTY; CheckpointStreamFactory storage = checkpointStorage.resolveCheckpointStorageLocation(checkpointId, checkpointOptions.getTargetLocation()); try { for (StreamOperatorWrapper<?, ?> operatorWrapper : operatorChain.getAllOperators(true)) { if (!operatorWrapper.isClosed()) { operatorSnapshotsInProgress.put( operatorWrapper.getStreamOperator().getOperatorID(), buildOperatorSnapshotFutures( checkpointMetaData, checkpointOptions, operatorChain, operatorWrapper.getStreamOperator(), isCanceled, channelStateWriteResult, storage)); } } } finally { checkpointStorage.clearCacheFor(checkpointId); } LOG.debug( "{} - finished synchronous part of checkpoint {}. Alignment duration: ms, snapshot duration ms", taskName, checkpointId, checkpointMetrics.getAlignmentDurationNanos() / 1_000_000, checkpointMetrics.getSyncDurationMillis()); checkpointMetrics.setSyncDurationMillis((System.nanoTime() - started) / 1_000_000); return true; }