Search in sources :

Example 1 with TrinoTransportException

use of io.trino.spi.TrinoTransportException in project trino by trinodb.

the class RequestErrorTracker method requestFailed.

public void requestFailed(Throwable reason) throws TrinoException {
    // cancellation is not a failure
    if (reason instanceof CancellationException) {
        return;
    }
    if (reason instanceof RejectedExecutionException) {
        throw new TrinoException(REMOTE_TASK_ERROR, reason);
    }
    // log failure message
    if (isExpectedError(reason)) {
        // don't print a stack for a known errors
        log.warn("Error %s %s: %s: %s", jobDescription, taskId, reason.getMessage(), taskUri);
    } else {
        log.warn(reason, "Error %s %s: %s", jobDescription, taskId, taskUri);
    }
    // remember the first 10 errors
    if (errorsSinceLastSuccess.size() < 10) {
        errorsSinceLastSuccess.add(reason);
    }
    // fail the task, 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
        TrinoException exception = new TrinoTransportException(TOO_MANY_REQUESTS_FAILED, fromUri(taskUri), format("%s (%s %s - %s failures, failure duration %s, total failed request time %s)", WORKER_NODE_ERROR, jobDescription, taskUri, backoff.getFailureCount(), backoff.getFailureDuration().convertTo(SECONDS), backoff.getFailureRequestTimeTotal().convertTo(SECONDS)));
        errorsSinceLastSuccess.forEach(exception::addSuppressed);
        throw exception;
    }
}
Also used : TrinoTransportException(io.trino.spi.TrinoTransportException) CancellationException(java.util.concurrent.CancellationException) TrinoException(io.trino.spi.TrinoException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with TrinoTransportException

use of io.trino.spi.TrinoTransportException in project trino by trinodb.

the class HttpRemoteTask method fail.

/**
 * Move the task directly to the failed state if there was a failure in this task
 */
@Override
public synchronized void fail(Throwable cause) {
    TaskStatus taskStatus = getTaskStatus();
    if (!taskStatus.getState().isDone()) {
        log.debug(cause, "Remote task %s failed with %s", taskStatus.getSelf(), cause);
    }
    TaskStatus status = failWith(getTaskStatus(), FAILED, ImmutableList.of(toFailure(cause)));
    taskStatusFetcher.updateTaskStatus(status);
    try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) {
        if (cause instanceof TrinoTransportException) {
            // task is unreachable
            cleanUpLocally();
        } else {
            // send abort to task
            scheduleAsyncCleanupRequest(new Backoff(maxErrorDuration), "abort", true);
        }
    }
}
Also used : TrinoTransportException(io.trino.spi.TrinoTransportException) SetThreadName(io.airlift.concurrent.SetThreadName) TaskStatus(io.trino.execution.TaskStatus)

Example 3 with TrinoTransportException

use of io.trino.spi.TrinoTransportException in project trino by trinodb.

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 TrinoTransportException) {
        remoteHost = ((TrinoTransportException) 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()), Arrays.stream(throwable.getStackTrace()).map(Objects::toString).collect(toImmutableList()), getErrorLocation(throwable), errorCode, remoteHost);
}
Also used : TrinoTransportException(io.trino.spi.TrinoTransportException) Objects(java.util.Objects) ErrorCode(io.trino.spi.ErrorCode) StandardErrorCode(io.trino.spi.StandardErrorCode) HostAddress(io.trino.spi.HostAddress) Failure(io.trino.execution.Failure) ExecutionFailureInfo(io.trino.execution.ExecutionFailureInfo)

Aggregations

TrinoTransportException (io.trino.spi.TrinoTransportException)3 SetThreadName (io.airlift.concurrent.SetThreadName)1 ExecutionFailureInfo (io.trino.execution.ExecutionFailureInfo)1 Failure (io.trino.execution.Failure)1 TaskStatus (io.trino.execution.TaskStatus)1 ErrorCode (io.trino.spi.ErrorCode)1 HostAddress (io.trino.spi.HostAddress)1 StandardErrorCode (io.trino.spi.StandardErrorCode)1 TrinoException (io.trino.spi.TrinoException)1 Objects (java.util.Objects)1 CancellationException (java.util.concurrent.CancellationException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1