{"record":{"id":"65a258d27fd41819","repo":"prestodb/presto","slug":"timed-out-waiting-for-query-preprocessor-after","errorCode":null,"errorMessage":"Timed out waiting for query preprocessor after ","messagePattern":"Timed out waiting for query preprocessor after ","errorType":"exception","errorClass":"QueryPreprocessorException","httpStatus":null,"severity":"error","filePath":"presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java","lineNumber":193,"sourceCode":"                        errorMessage.map(message1 -> \"\\n===\\n\" + message1 + \"\\n===\").orElse(\"\"));\n            }\n            return result;\n        });\n\n        try {\n            return task.get(timeout.toMillis(), MILLISECONDS);\n        }\n        catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new QueryPreprocessorException(\"Interrupted while preprocessing query\");\n        }\n        catch (ExecutionException e) {\n            Throwable cause = e.getCause();\n            propagateIfPossible(cause, QueryPreprocessorException.class);\n            throw new QueryPreprocessorException(\"Error preprocessing query: \" + cause.getMessage(), cause);\n        }\n        catch (TimeoutException e) {\n            throw new QueryPreprocessorException(\"Timed out waiting for query preprocessor after \" + timeout);\n        }\n        finally {\n            Process process = processReference.get();\n            if (process != null) {\n                process.destroyForcibly();\n            }\n            task.cancel(true);\n        }\n    }\n\n    private static <T> Future<T> executeInNewThread(String threadName, Callable<T> callable)\n    {\n        FutureTask<T> task = new FutureTask<>(callable);\n        Thread thread = new Thread(task);\n        thread.setName(threadName);\n        thread.setDaemon(true);\n        thread.start();\n        return task;","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java#L175-L211","documentation":"QueryPreprocessorException thrown when the preprocessor task does not complete within the configured timeout (Future.get(timeout)). On timeout the library also destroys the preprocessor process forcibly in the finally block. The message includes the elapsed timeout value that was exceeded.","triggerScenarios":"The external --preprocessor-command process hangs or takes longer than the preprocessor timeout while rewriting a query, so task.get(timeout.toMillis(), MILLISECONDS) throws TimeoutException.","commonSituations":"Preprocessor script waits on stdin/network that never arrives; slow preprocessor (cold start, large queries) exceeding the timeout; deadlock in the preprocessor reading/writing streams.","solutions":["Increase the preprocessor timeout so slow scripts can finish.","Profile/speed up the preprocessor; make it stateless and fast.","Check the script for blocking reads (stdin waits, network calls) and remove them.","Test the preprocessor with representative query sizes to measure realistic runtime.","If the preprocessor hangs intermittently, add its own internal timeout/failsafe exit."],"exampleFix":"// before\n./presto --server ... --preprocessor-command ./slow-preprocessor.sh   # hangs > timeout\n// after\ntimeout 5 ./slow-preprocessor.sh  # self-limiting; also raise CLI preprocessor timeout","handlingStrategy":"try-catch","validationCode":"# bound the preprocessor's own runtime\ntimeout 10s your-preprocessor.sh < sample.sql && echo OK","typeGuard":null,"tryCatchPattern":"try {\n    preprocessQuery(query);\n} catch (QueryPreprocessorException e) {\n    if (e.getMessage().startsWith(\"Timed out waiting for query preprocessor\")) {\n        log.error(\"preprocessor exceeded timeout; increase timeout or speed up the command\");\n    }\n    throw e;\n}","preventionTips":["Set the preprocessor timeout generously for your largest queries.","Avoid blocking reads (stdin, network) inside the preprocessor.","Monitor preprocessor latency and alert before the timeout is hit.","Add an internal watchdog to the preprocessor script itself."],"tags":["cli","timeout","query-preprocessing","subprocess"],"backgroundTag":"preprocessor-timeout","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"}