Search in sources :

Example 1 with PrestoTransportException

use of com.facebook.presto.spi.PrestoTransportException in project presto by prestodb.

the class TestThriftTaskStatus method getExecutionFailureInfos.

private List<ExecutionFailureInfo> getExecutionFailureInfos() {
    IOException ioException = new IOException("Remote call timed out");
    ioException.addSuppressed(new IOException("Thrift call timed out"));
    PrestoTransportException prestoTransportException = new PrestoTransportException(TOO_MANY_REQUESTS_FAILED, REMOTE_HOST, "Too many requests failed", new PrestoException(REMOTE_TASK_ERROR, "Remote Task Error"));
    ParsingException parsingException = new ParsingException("Parsing Exception", new NodeLocation(100, 1));
    return Failures.toFailures(ImmutableList.of(ioException, prestoTransportException, parsingException));
}
Also used : NodeLocation(com.facebook.presto.sql.tree.NodeLocation) ParsingException(com.facebook.presto.sql.parser.ParsingException) PrestoException(com.facebook.presto.spi.PrestoException) IOException(java.io.IOException) PrestoTransportException(com.facebook.presto.spi.PrestoTransportException)

Example 2 with PrestoTransportException

use of com.facebook.presto.spi.PrestoTransportException in project presto by prestodb.

the class RequestErrorTracker method requestFailed.

public void requestFailed(Throwable reason) throws PrestoException {
    // cancellation is not a failure
    if (reason instanceof CancellationException) {
        return;
    }
    if (reason instanceof RejectedExecutionException) {
        throw new PrestoException(errorCode, reason);
    }
    // log failure message
    if (isExpectedError(reason)) {
        // don't print a stack for a known errors
        log.warn("Error " + jobDescription + " %s: %s: %s", id, reason.getMessage(), uri);
    } else {
        log.warn(reason, "Error " + jobDescription + " %s: %s", id, uri);
    }
    // remember the first 10 errors
    if (errorsSinceLastSuccess.size() < 10) {
        errorsSinceLastSuccess.add(reason);
    }
    // fail the operation, if we have more than X failures in a row and more than Y seconds have passed since the last request
    if (backoff.failure()) {
        // it is weird to mark the task failed locally and then cancel the remote task, but there is no way to tell a remote task that it is failed
        PrestoException exception = new PrestoTransportException(TOO_MANY_REQUESTS_FAILED, fromUri(uri), format("%s (%s %s - %s failures, failure duration %s, total failed request time %s)", nodeErrorMessage, jobDescription, uri, backoff.getFailureCount(), backoff.getFailureDuration().convertTo(SECONDS), backoff.getFailureRequestTimeTotal().convertTo(SECONDS)));
        errorsSinceLastSuccess.forEach(exception::addSuppressed);
        throw exception;
    }
}
Also used : CancellationException(java.util.concurrent.CancellationException) PrestoException(com.facebook.presto.spi.PrestoException) PrestoTransportException(com.facebook.presto.spi.PrestoTransportException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 3 with PrestoTransportException

use of com.facebook.presto.spi.PrestoTransportException 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)

Aggregations

PrestoTransportException (com.facebook.presto.spi.PrestoTransportException)3 PrestoException (com.facebook.presto.spi.PrestoException)2 ExecutionFailureInfo (com.facebook.presto.execution.ExecutionFailureInfo)1 Failure (com.facebook.presto.execution.Failure)1 ErrorCode (com.facebook.presto.spi.ErrorCode)1 HostAddress (com.facebook.presto.spi.HostAddress)1 StandardErrorCode (com.facebook.presto.spi.StandardErrorCode)1 ParsingException (com.facebook.presto.sql.parser.ParsingException)1 NodeLocation (com.facebook.presto.sql.tree.NodeLocation)1 IOException (java.io.IOException)1 CancellationException (java.util.concurrent.CancellationException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1