Skip to content

Commit

Permalink
Throw error upon purged retryable queries
Browse files Browse the repository at this point in the history
  • Loading branch information
highker committed Apr 23, 2021
1 parent ad51d4c commit 68f6cff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.facebook.presto.server.ServerConfig;
import com.facebook.presto.server.SessionContext;
import com.facebook.presto.spi.ErrorCode;
import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.QueryId;
import com.facebook.presto.sql.parser.SqlParserOptions;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -72,6 +73,7 @@
import static com.facebook.presto.execution.QueryState.QUEUED;
import static com.facebook.presto.server.security.RoleType.USER;
import static com.facebook.presto.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static com.facebook.presto.spi.StandardErrorCode.RETRY_QUERY_NOT_FOUND;
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Verify.verify;
Expand Down Expand Up @@ -191,6 +193,11 @@ public Response retryFailedQuery(
{
Query failedQuery = queries.get(queryId);

if (failedQuery == null) {
// TODO: purge retryable queries slower than normal ones
throw new PrestoException(RETRY_QUERY_NOT_FOUND, "failed to find the query to retry with ID " + queryId);
}

Query query = new Query(failedQuery.getQuery(), failedQuery.getSessionContext(), dispatchManager, queryResultsProvider, failedQuery.getRetryCount() + 1);
queries.put(query.getQueryId(), query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public enum StandardErrorCode
NODE_SELECTION_NOT_SUPPORTED(0x0001_001E, INTERNAL_ERROR),
SPOOLING_STORAGE_ERROR(0x0001_001F, INTERNAL_ERROR),
SERIALIZED_PAGE_CHECKSUM_ERROR(0x0001_0020, INTERNAL_ERROR),
RETRY_QUERY_NOT_FOUND(0x0001_0021, INTERNAL_ERROR),

GENERIC_INSUFFICIENT_RESOURCES(0x0002_0000, INSUFFICIENT_RESOURCES),
EXCEEDED_GLOBAL_MEMORY_LIMIT(0x0002_0001, INSUFFICIENT_RESOURCES),
Expand Down

0 comments on commit 68f6cff

Please sign in to comment.