prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Target query is not running: ${queryId}

What it means

The kill_query system procedure checks the target query's state before failing it. If QueryState.isDone() is already true (FINISHED, FAILED, or CANCELED), there is nothing to kill, so Presto throws NOT_SUPPORTED with 'Target query is not running: <queryId>'. This is the pre-kill guard branch; the same error can also surface after a lost race (see error 1805).

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/connector/system/KillQueryProcedure.java:61

    private final QueryManager queryManager;

    @Inject
    public KillQueryProcedure(QueryManager queryManager)
    {
        this.queryManager = requireNonNull(queryManager, "queryManager is null");
    }

    @UsedByGeneratedCode
    public void killQuery(String queryId, String message)
    {
        QueryId query = parseQueryId(queryId);

        try {
            QueryState state = queryManager.getQueryState(query);

            // check before killing to provide the proper error message (this is racy)
            if (state.isDone()) {
                throw new PrestoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
            }

            queryManager.failQuery(query, createKillQueryException(message));

            // verify if the query was killed (if not, we lost the race)
            if (!ADMINISTRATIVELY_KILLED.toErrorCode().equals(queryManager.getQueryInfo(query).getErrorCode())) {
                throw new PrestoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
            }
        }
        catch (NoSuchElementException e) {
            throw new PrestoException(NOT_FOUND, "Target query not found: " + queryId);
        }
    }

    public Procedure getProcedure()
    {
        return new Procedure(
                "runtime",

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check the query state via the query manager/UI before calling kill_query; skip if done.
  2. Fetch the fresh queryId right before killing rather than caching it in automation.
  3. Treat this NOT_SUPPORTED error as idempotent success in scripts (the goal — query not running — is achieved).

Example fix

// before
QueryState state = queryManager.getQueryState(query);
if (state.isDone()) {
    throw new PrestoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
}
// after
QueryState state = queryManager.getQueryState(query);
if (state.isDone()) {
    log.info("Query %s already finished with state %s; nothing to kill", queryId, state);
    return;
}
Defensive patterns

Strategy: try-catch

Validate before calling

QueryState state = queryManager.getQueryState(query);
if (state.isDone()) { skip(); return; }

Try / catch

try { killQuery(queryId, message); }
catch (PrestoException e) { if (e.getErrorCode() == StandardErrorCode.NOT_SUPPORTED.toErrorCode() && e.getMessage().contains("not running")) { /* treat as success: idempotent kill */ } else throw e; }

Prevention

When it happens

Trigger: CALL system.kill_query(query_id => '...', message => '...') where the query has already completed; also killed-before-check racy completions between the state check and the call.

Common situations: Operators killing a long-running query that finished while the console was open; automation scripts killing by a stale query ID; retries of a kill that already succeeded.

Understand the failure class

Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/0c648475961afcb0. Report an issue: GitHub.