Search in sources :

Example 6 with ExecutionFailureInfo

use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.

the class FailedDispatchQueryFactory method createFailedDispatchQuery.

public FailedDispatchQuery createFailedDispatchQuery(Session session, String query, Optional<ResourceGroupId> resourceGroup, Throwable throwable) {
    ExecutionFailureInfo failure = toFailure(throwable);
    FailedDispatchQuery failedDispatchQuery = new FailedDispatchQuery(session, query, locationFactory.createQueryLocation(session.getQueryId()), resourceGroup, failure, executor);
    BasicQueryInfo queryInfo = failedDispatchQuery.getBasicQueryInfo();
    queryMonitor.queryCreatedEvent(queryInfo);
    queryMonitor.queryImmediateFailureEvent(queryInfo, failure);
    return failedDispatchQuery;
}
Also used : BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) ExecutionFailureInfo(com.facebook.presto.execution.ExecutionFailureInfo)

Example 7 with ExecutionFailureInfo

use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.

the class Failures method toFailure.

private static ExecutionFailureInfo toFailure(Throwable throwable, Set<Throwable> seenFailures) {
    if (throwable == null) {
        return null;
    }
    String type;
    HostAddress remoteHost = null;
    if (throwable instanceof Failure) {
        type = ((Failure) throwable).getType();
    } else {
        Class<?> clazz = throwable.getClass();
        type = firstNonNull(clazz.getCanonicalName(), clazz.getName());
    }
    if (throwable instanceof PrestoTransportException) {
        remoteHost = ((PrestoTransportException) throwable).getRemoteHost();
    }
    if (seenFailures.contains(throwable)) {
        return new ExecutionFailureInfo(type, "[cyclic] " + throwable.getMessage(), null, ImmutableList.of(), ImmutableList.of(), null, GENERIC_INTERNAL_ERROR.toErrorCode(), remoteHost);
    }
    seenFailures.add(throwable);
    ExecutionFailureInfo cause = toFailure(throwable.getCause(), seenFailures);
    ErrorCode errorCode = toErrorCode(throwable);
    if (errorCode == null) {
        if (cause == null) {
            errorCode = GENERIC_INTERNAL_ERROR.toErrorCode();
        } else {
            errorCode = cause.getErrorCode();
        }
    }
    return new ExecutionFailureInfo(type, throwable.getMessage(), cause, Arrays.stream(throwable.getSuppressed()).map(failure -> toFailure(failure, seenFailures)).collect(toImmutableList()), Lists.transform(asList(throwable.getStackTrace()), toStringFunction()), getErrorLocation(throwable), errorCode, remoteHost);
}
Also used : ErrorCode(com.facebook.presto.spi.ErrorCode) StandardErrorCode(com.facebook.presto.spi.StandardErrorCode) HostAddress(com.facebook.presto.spi.HostAddress) PrestoTransportException(com.facebook.presto.spi.PrestoTransportException) Failure(com.facebook.presto.execution.Failure) ExecutionFailureInfo(com.facebook.presto.execution.ExecutionFailureInfo)

Example 8 with ExecutionFailureInfo

use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.

the class PrestoSparkExecutionExceptionFactory method toPrestoSparkExecutionException.

public PrestoSparkExecutionException toPrestoSparkExecutionException(Throwable throwable) {
    ExecutionFailureInfo failureInfo = toFailure(throwable);
    byte[] serialized = codec.toJsonBytes(failureInfo);
    byte[] compressed = compress(serialized);
    String encodedExecutionFailureInfo = Base64.getEncoder().encodeToString(compressed);
    if (isRetryable(failureInfo)) {
        return new PrestoSparkRetryableExecutionException(throwable.getMessage(), encodedExecutionFailureInfo, throwable);
    } else {
        return new PrestoSparkNonRetryableExecutionException(throwable.getMessage(), encodedExecutionFailureInfo, throwable);
    }
}
Also used : PrestoSparkRetryableExecutionException(com.facebook.presto.spark.classloader_interface.PrestoSparkRetryableExecutionException) PrestoSparkNonRetryableExecutionException(com.facebook.presto.spark.classloader_interface.PrestoSparkNonRetryableExecutionException) ExecutionFailureInfo(com.facebook.presto.execution.ExecutionFailureInfo)

Example 9 with ExecutionFailureInfo

use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.

the class PrestoSparkExecutionExceptionFactory method extractExecutionFailureInfo.

private Optional<ExecutionFailureInfo> extractExecutionFailureInfo(String message) {
    Matcher matcher = PATTERN.matcher(message);
    if (matcher.matches()) {
        String encodedFailureInfo = matcher.group(1);
        byte[] decoded = Base64.getDecoder().decode(encodedFailureInfo);
        byte[] decompressed = decompress(decoded);
        ExecutionFailureInfo failureInfo = codec.fromJson(decompressed);
        return Optional.of(failureInfo);
    }
    return Optional.empty();
}
Also used : Matcher(java.util.regex.Matcher) ExecutionFailureInfo(com.facebook.presto.execution.ExecutionFailureInfo)

Example 10 with ExecutionFailureInfo

use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.

the class TestPrestoSparkExecutionExceptionFactory method testRoundTrip.

@Test
public void testRoundTrip() {
    String causeMessage = "cause message";
    IOException cause = new IOException(causeMessage);
    String suppressedMessage = "suppressed message";
    IllegalArgumentException suppressed = new IllegalArgumentException(suppressedMessage);
    String message = "presto exception message";
    PrestoException prestoException = new PrestoException(NOT_SUPPORTED, message, cause);
    prestoException.addSuppressed(suppressed);
    PrestoSparkExecutionException executionException = factory.toPrestoSparkExecutionException(prestoException);
    Optional<ExecutionFailureInfo> failure = factory.extractExecutionFailureInfo(executionException);
    assertTrue(failure.isPresent());
    assertFailure(failure.get().toFailure(), prestoException);
    ExceptionFailure exceptionFailure = new ExceptionFailure(executionException, asScalaBuffer(ImmutableList.of()));
    SparkException sparkException = new SparkException(SPARK_EXCEPTION_STRING + exceptionFailure.toErrorString());
    failure = factory.extractExecutionFailureInfo(sparkException);
    assertTrue(failure.isPresent());
    assertFailure(failure.get().toFailure(), prestoException);
}
Also used : SparkException(org.apache.spark.SparkException) ExceptionFailure(org.apache.spark.ExceptionFailure) PrestoException(com.facebook.presto.spi.PrestoException) IOException(java.io.IOException) PrestoSparkExecutionException(com.facebook.presto.spark.classloader_interface.PrestoSparkExecutionException) ExecutionFailureInfo(com.facebook.presto.execution.ExecutionFailureInfo) Test(org.testng.annotations.Test)

Aggregations

ExecutionFailureInfo (com.facebook.presto.execution.ExecutionFailureInfo)10 PrestoException (com.facebook.presto.spi.PrestoException)5 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)4 Test (org.testng.annotations.Test)2 Failure (com.facebook.presto.execution.Failure)1 QueryInfo (com.facebook.presto.execution.QueryInfo)1 QueryStats (com.facebook.presto.execution.QueryStats)1 SqlStageExecution (com.facebook.presto.execution.SqlStageExecution)1 StageExecutionInfo (com.facebook.presto.execution.StageExecutionInfo)1 StageInfo (com.facebook.presto.execution.StageInfo)1 TaskInfo (com.facebook.presto.execution.TaskInfo)1 PrestoSparkExecutionException (com.facebook.presto.spark.classloader_interface.PrestoSparkExecutionException)1 PrestoSparkNonRetryableExecutionException (com.facebook.presto.spark.classloader_interface.PrestoSparkNonRetryableExecutionException)1 PrestoSparkRetryableExecutionException (com.facebook.presto.spark.classloader_interface.PrestoSparkRetryableExecutionException)1 SerializedTaskInfo (com.facebook.presto.spark.classloader_interface.SerializedTaskInfo)1 PlanAndMore (com.facebook.presto.spark.planner.PrestoSparkQueryPlanner.PlanAndMore)1 ErrorCode (com.facebook.presto.spi.ErrorCode)1 HostAddress (com.facebook.presto.spi.HostAddress)1 PrestoTransportException (com.facebook.presto.spi.PrestoTransportException)1 StandardErrorCode (com.facebook.presto.spi.StandardErrorCode)1