use of io.prestosql.spi.StandardErrorCode.QUERY_EXPIRE in project hetu-core by openlookeng.
the class SqlQueryManager method killExpiredQuery.
/**
* Kill query when expired, state has already been updated in StateFetcher.
*/
private void killExpiredQuery() {
if (!isMultiCoordinatorEnabled()) {
return;
}
List<QueryExecution> localRunningQueries = queryTracker.getAllQueries().stream().filter(query -> query.getState() == RUNNING).collect(toImmutableList());
Map<String, SharedQueryState> queries = StateCacheStore.get().getCachedStates(StateStoreConstants.FINISHED_QUERY_STATE_COLLECTION_NAME);
if (queries != null) {
Set<String> expiredQueryIds = queries.entrySet().stream().filter(entry -> isQueryExpired(entry.getValue())).map(entry -> entry.getKey()).collect(Collectors.toSet());
if (!expiredQueryIds.isEmpty()) {
for (QueryExecution localQuery : localRunningQueries) {
if (expiredQueryIds.contains(localQuery.getQueryId().getId())) {
localQuery.fail(new PrestoException(QUERY_EXPIRE, "Query killed because the query has expired. Please try again in a few minutes."));
}
}
}
}
}
Aggregations