{"record":{"id":"f2280e0e2c549f6b","repo":"prestodb/presto","slug":"query-timeout-seconds-must-be-positive","errorCode":null,"errorMessage":"Query timeout seconds must be positive","messagePattern":"Query timeout seconds must be positive","errorType":"validation","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java","lineNumber":171,"sourceCode":"        checkOpen();\n        escapeProcessing.set(enable);\n    }\n\n    @Override\n    public int getQueryTimeout()\n            throws SQLException\n    {\n        checkOpen();\n        return queryTimeoutSeconds.get();\n    }\n\n    @Override\n    public void setQueryTimeout(int seconds)\n            throws SQLException\n    {\n        checkOpen();\n        if (seconds < 0) {\n            throw new SQLException(\"Query timeout seconds must be positive\");\n        }\n        queryTimeoutSeconds.set(seconds);\n    }\n\n    @Override\n    public void cancel()\n            throws SQLException\n    {\n        checkOpen();\n\n        StatementClient client = executingClient.get();\n        if (client != null) {\n            client.close();\n        }\n\n        closeResultSet();\n    }\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java#L153-L189","documentation":"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.","triggerScenarios":"Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:171 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass 0 for no timeout or a positive number of seconds for the query timeout","Clamp/validate the timeout configuration value before calling setQueryTimeout","Catch SQLException when timeouts are derived from user configuration"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}