use of org.apache.flink.runtime.checkpoint.CheckpointFailureReason in project flink by apache.
the class AsyncCheckpointRunnableTest method testDeclineAsyncCheckpoint.
@Test
public void testDeclineAsyncCheckpoint() {
CheckpointFailureReason originalReason = CheckpointFailureReason.CHECKPOINT_DECLINED_INPUT_END_OF_STREAM;
final Map<OperatorID, OperatorSnapshotFutures> snapshotsInProgress = new HashMap<>();
snapshotsInProgress.put(new OperatorID(), new OperatorSnapshotFutures(DoneFuture.of(SnapshotResult.empty()), DoneFuture.of(SnapshotResult.empty()), DoneFuture.of(SnapshotResult.empty()), DoneFuture.of(SnapshotResult.empty()), ExceptionallyDoneFuture.of(new CheckpointException(originalReason)), DoneFuture.of(SnapshotResult.empty())));
final TestEnvironment environment = new TestEnvironment();
final AsyncCheckpointRunnable runnable = createAsyncRunnable(snapshotsInProgress, environment, false, true);
runnable.run();
Assert.assertSame(environment.getCause().getCheckpointFailureReason(), originalReason);
}
use of org.apache.flink.runtime.checkpoint.CheckpointFailureReason in project flink by apache.
the class AsyncCheckpointRunnable method handleExecutionException.
private void handleExecutionException(Exception e) {
boolean didCleanup = false;
AsyncCheckpointState currentState = asyncCheckpointState.get();
while (AsyncCheckpointState.DISCARDED != currentState) {
if (asyncCheckpointState.compareAndSet(currentState, AsyncCheckpointState.DISCARDED)) {
didCleanup = true;
try {
cleanup();
} catch (Exception cleanupException) {
e.addSuppressed(cleanupException);
}
Exception checkpointException = new Exception("Could not materialize checkpoint " + checkpointMetaData.getCheckpointId() + " for operator " + taskName + '.', e);
if (isTaskRunning.get()) {
// failing the task.
try {
Optional<CheckpointException> underlyingCheckpointException = ExceptionUtils.findThrowable(checkpointException, CheckpointException.class);
// If this failure is already a CheckpointException, do not overwrite the
// original CheckpointFailureReason
CheckpointFailureReason reportedFailureReason = underlyingCheckpointException.map(exception -> exception.getCheckpointFailureReason()).orElse(CheckpointFailureReason.CHECKPOINT_ASYNC_EXCEPTION);
taskEnvironment.declineCheckpoint(checkpointMetaData.getCheckpointId(), new CheckpointException(reportedFailureReason, checkpointException));
} catch (Exception unhandled) {
AsynchronousException asyncException = new AsynchronousException(unhandled);
asyncExceptionHandler.handleAsyncException("Failure in asynchronous checkpoint materialization", asyncException);
}
} else {
// We never decline checkpoint after task is not running to avoid unexpected job
// failover, which caused by exceeding checkpoint tolerable failure threshold.
LOG.info("Ignore decline of checkpoint {} as task is not running anymore.", checkpointMetaData.getCheckpointId());
}
currentState = AsyncCheckpointState.DISCARDED;
} else {
currentState = asyncCheckpointState.get();
}
}
if (!didCleanup) {
LOG.trace("Caught followup exception from a failed checkpoint thread. This can be ignored.", e);
}
}
Aggregations