Search in sources :

Example 11 with ErrorInfo

use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.

the class ExecutingTest method testFailureReportedViaUpdateTaskExecutionStateCausesRestart.

@Test
public void testFailureReportedViaUpdateTaskExecutionStateCausesRestart() throws Exception {
    try (MockExecutingContext ctx = new MockExecutingContext()) {
        StateTrackingMockExecutionGraph returnsFailedStateExecutionGraph = new StateTrackingMockExecutionGraph();
        Executing exec = new ExecutingStateBuilder().setExecutionGraph(returnsFailedStateExecutionGraph).build(ctx);
        ctx.setHowToHandleFailure((failure) -> FailureResult.canRestart(failure, Duration.ZERO));
        ctx.setExpectRestarting(assertNonNull());
        Exception exception = new RuntimeException();
        TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
        returnsFailedStateExecutionGraph.registerExecution(execution);
        TaskExecutionStateTransition taskExecutionStateTransition = createFailingStateTransition(execution.getAttemptId(), exception);
        exec.updateTaskExecutionState(taskExecutionStateTransition);
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) JobException(org.apache.flink.runtime.JobException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Test(org.junit.Test)

Example 12 with ErrorInfo

use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.

the class ExecutingTest method testFalseReportsViaUpdateTaskExecutionStateAreIgnored.

@Test
public void testFalseReportsViaUpdateTaskExecutionStateAreIgnored() throws Exception {
    try (MockExecutingContext ctx = new MockExecutingContext()) {
        MockExecutionGraph returnsFailedStateExecutionGraph = new MockExecutionGraph(false, Collections::emptyList);
        Executing exec = new ExecutingStateBuilder().setExecutionGraph(returnsFailedStateExecutionGraph).build(ctx);
        Exception exception = new RuntimeException();
        TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
        returnsFailedStateExecutionGraph.registerExecution(execution);
        TaskExecutionStateTransition taskExecutionStateTransition = createFailingStateTransition(execution.getAttemptId(), exception);
        exec.updateTaskExecutionState(taskExecutionStateTransition);
        ctx.assertNoStateTransition();
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) Collections(java.util.Collections) JobException(org.apache.flink.runtime.JobException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Test(org.junit.Test)

Example 13 with ErrorInfo

use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.

the class ApplicationDispatcherBootstrapITCase method testSubmitFailedJobOnApplicationError.

@Test
public void testSubmitFailedJobOnApplicationError() throws Exception {
    final Deadline deadline = Deadline.fromNow(TIMEOUT);
    final JobID jobId = new JobID();
    final Configuration configuration = new Configuration();
    configuration.set(HighAvailabilityOptions.HA_MODE, HighAvailabilityMode.ZOOKEEPER.name());
    configuration.set(DeploymentOptions.TARGET, EmbeddedExecutor.NAME);
    configuration.set(ClientOptions.CLIENT_RETRY_PERIOD, Duration.ofMillis(100));
    configuration.set(DeploymentOptions.SHUTDOWN_ON_APPLICATION_FINISH, false);
    configuration.set(DeploymentOptions.SUBMIT_FAILED_JOB_ON_APPLICATION_ERROR, true);
    configuration.set(PipelineOptionsInternal.PIPELINE_FIXED_JOB_ID, jobId.toHexString());
    final TestingMiniClusterConfiguration clusterConfiguration = TestingMiniClusterConfiguration.newBuilder().setConfiguration(configuration).build();
    final EmbeddedHaServicesWithLeadershipControl haServices = new EmbeddedHaServicesWithLeadershipControl(TestingUtils.defaultExecutor());
    final TestingMiniCluster.Builder clusterBuilder = TestingMiniCluster.newBuilder(clusterConfiguration).setHighAvailabilityServicesSupplier(() -> haServices).setDispatcherResourceManagerComponentFactorySupplier(createApplicationModeDispatcherResourceManagerComponentFactorySupplier(clusterConfiguration.getConfiguration(), FailingJob.getProgram()));
    try (final MiniCluster cluster = clusterBuilder.build()) {
        // start mini cluster and submit the job
        cluster.start();
        // wait until the failed job has been submitted
        awaitJobStatus(cluster, jobId, JobStatus.FAILED, deadline);
        final ArchivedExecutionGraph graph = cluster.getArchivedExecutionGraph(jobId).get();
        assertThat(graph.getJobID()).isEqualTo(jobId);
        assertThat(graph.getJobName()).isEqualTo(ApplicationDispatcherBootstrap.FAILED_JOB_NAME);
        assertThat(graph.getFailureInfo()).isNotNull().extracting(ErrorInfo::getException).extracting(e -> e.deserializeError(Thread.currentThread().getContextClassLoader())).satisfies(e -> assertThat(e).isInstanceOf(ProgramInvocationException.class).hasRootCauseInstanceOf(RuntimeException.class).hasRootCauseMessage(FailingJob.EXCEPTION_MESSAGE));
    }
}
Also used : TestingMiniCluster(org.apache.flink.runtime.minicluster.TestingMiniCluster) Deadline(org.apache.flink.api.common.time.Deadline) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) EmbeddedHaServicesWithLeadershipControl(org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedHaServicesWithLeadershipControl) TestingMiniClusterConfiguration(org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EmbeddedJobResultStore(org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedJobResultStore) ExceptionUtils(org.apache.flink.util.ExceptionUtils) CompletableFuture(java.util.concurrent.CompletableFuture) JobStatus(org.apache.flink.api.common.JobStatus) Supplier(java.util.function.Supplier) EmbeddedExecutor(org.apache.flink.client.deployment.application.executors.EmbeddedExecutor) PipelineOptionsInternal(org.apache.flink.configuration.PipelineOptionsInternal) JobResult(org.apache.flink.runtime.jobmaster.JobResult) TestLoggerExtension(org.apache.flink.util.TestLoggerExtension) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) BlockingJob(org.apache.flink.client.testjar.BlockingJob) DefaultDispatcherRunnerFactory(org.apache.flink.runtime.dispatcher.runner.DefaultDispatcherRunnerFactory) DefaultDispatcherResourceManagerComponentFactory(org.apache.flink.runtime.entrypoint.component.DefaultDispatcherResourceManagerComponentFactory) FlinkAssertions(org.apache.flink.core.testutils.FlinkAssertions) Duration(java.time.Duration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) ErrorHandlingSubmissionJob(org.apache.flink.client.testjar.ErrorHandlingSubmissionJob) DeploymentOptions(org.apache.flink.configuration.DeploymentOptions) HighAvailabilityMode(org.apache.flink.runtime.jobmanager.HighAvailabilityMode) ClientOptions(org.apache.flink.client.cli.ClientOptions) FailingJob(org.apache.flink.client.testjar.FailingJob) DispatcherResourceManagerComponentFactory(org.apache.flink.runtime.entrypoint.component.DispatcherResourceManagerComponentFactory) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) TestingMiniCluster(org.apache.flink.runtime.minicluster.TestingMiniCluster) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) Configuration(org.apache.flink.configuration.Configuration) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) JobRestEndpointFactory(org.apache.flink.runtime.rest.JobRestEndpointFactory) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test) ExecutionException(java.util.concurrent.ExecutionException) TestingUtils(org.apache.flink.testutils.TestingUtils) JobResultEntry(org.apache.flink.runtime.highavailability.JobResultEntry) JobID(org.apache.flink.api.common.JobID) FlinkJobNotFoundException(org.apache.flink.runtime.messages.FlinkJobNotFoundException) TestingJobResultStore(org.apache.flink.runtime.testutils.TestingJobResultStore) PackagedProgram(org.apache.flink.client.program.PackagedProgram) JobResultStore(org.apache.flink.runtime.highavailability.JobResultStore) SessionDispatcherFactory(org.apache.flink.runtime.dispatcher.SessionDispatcherFactory) CommonTestUtils(org.apache.flink.runtime.testutils.CommonTestUtils) StandaloneResourceManagerFactory(org.apache.flink.runtime.resourcemanager.StandaloneResourceManagerFactory) HighAvailabilityOptions(org.apache.flink.configuration.HighAvailabilityOptions) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException) TestingMiniClusterConfiguration(org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration) Configuration(org.apache.flink.configuration.Configuration) TestingMiniClusterConfiguration(org.apache.flink.runtime.minicluster.TestingMiniClusterConfiguration) Deadline(org.apache.flink.api.common.time.Deadline) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) EmbeddedHaServicesWithLeadershipControl(org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedHaServicesWithLeadershipControl) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) TestingMiniCluster(org.apache.flink.runtime.minicluster.TestingMiniCluster) JobID(org.apache.flink.api.common.JobID) Test(org.junit.jupiter.api.Test)

Example 14 with ErrorInfo

use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.

the class JobResultTest method testFailedJobIsFailureResult.

@Test
public void testFailedJobIsFailureResult() {
    final JobResult jobResult = JobResult.createFrom(new ArchivedExecutionGraphBuilder().setJobID(new JobID()).setState(JobStatus.FAILED).setFailureCause(new ErrorInfo(new FlinkException("Test exception"), 42L)).build());
    assertThat(jobResult.isSuccess(), is(false));
}
Also used : ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 15 with ErrorInfo

use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.

the class ExecutionGraphInfoTest method testExecutionGraphHistoryBeingDerivedFromFailedExecutionGraph.

@Test
public void testExecutionGraphHistoryBeingDerivedFromFailedExecutionGraph() {
    final ArchivedExecutionGraph executionGraph = ArchivedExecutionGraph.createSparseArchivedExecutionGraph(new JobID(), "test job name", JobStatus.FAILED, new RuntimeException("Expected RuntimeException"), null, System.currentTimeMillis());
    final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(executionGraph);
    final ErrorInfo failureInfo = executionGraphInfo.getArchivedExecutionGraph().getFailureInfo();
    final RootExceptionHistoryEntry actualEntry = Iterables.getOnlyElement(executionGraphInfo.getExceptionHistory());
    assertThat(failureInfo).isNotNull();
    assertThat(failureInfo.getException()).isEqualTo(actualEntry.getException());
    assertThat(failureInfo.getTimestamp()).isEqualTo(actualEntry.getTimestamp());
    assertThat(actualEntry.isGlobal()).isTrue();
    assertThat(actualEntry.getFailingTaskName()).isNull();
    assertThat(actualEntry.getTaskManagerLocation()).isNull();
}
Also used : RootExceptionHistoryEntry(org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) JobID(org.apache.flink.api.common.JobID) Test(org.junit.jupiter.api.Test)

Aggregations

ErrorInfo (org.apache.flink.runtime.executiongraph.ErrorInfo)27 Test (org.junit.Test)17 JobID (org.apache.flink.api.common.JobID)9 TaskExecutionStateTransition (org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition)8 TestingAccessExecution (org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution)8 ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)7 FlinkException (org.apache.flink.util.FlinkException)7 JobStatus (org.apache.flink.api.common.JobStatus)5 CompletableFuture (java.util.concurrent.CompletableFuture)4 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)4 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)4 RootExceptionHistoryEntry (org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry)4 Duration (java.time.Duration)3 Deadline (org.apache.flink.api.common.time.Deadline)3 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)3 ArchivedExecutionVertex (org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex)3 LocalTaskManagerLocation (org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2