prestodb/presto · error · SQLException

Query timeout seconds must be positive

Error message

Query timeout seconds must be positive

What it means

setQueryTimeout in PrestoStatement validates its input after checkOpen(): a negative seconds value is rejected with this SQLException because a query timeout must be zero (no timeout) or positive. Note 0 is accepted despite the message wording.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:171

        checkOpen();
        escapeProcessing.set(enable);
    }

    @Override
    public int getQueryTimeout()
            throws SQLException
    {
        checkOpen();
        return queryTimeoutSeconds.get();
    }

    @Override
    public void setQueryTimeout(int seconds)
            throws SQLException
    {
        checkOpen();
        if (seconds < 0) {
            throw new SQLException("Query timeout seconds must be positive");
        }
        queryTimeoutSeconds.set(seconds);
    }

    @Override
    public void cancel()
            throws SQLException
    {
        checkOpen();

        StatementClient client = executingClient.get();
        if (client != null) {
            client.close();
        }

        closeResultSet();
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Pass 0 for no timeout or a positive number of seconds for the query timeout
  2. Clamp/validate the timeout configuration value before calling setQueryTimeout
  3. Catch SQLException when timeouts are derived from user configuration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:171 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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