prestodb/presto · error · QueryPreprocessorException
Timed out waiting for query preprocessor after
Error message
Timed out waiting for query preprocessor after
What it means
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.
Source
Thrown at presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java:193
errorMessage.map(message1 -> "\n===\n" + message1 + "\n===").orElse(""));
}
return result;
});
try {
return task.get(timeout.toMillis(), MILLISECONDS);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new QueryPreprocessorException("Interrupted while preprocessing query");
}
catch (ExecutionException e) {
Throwable cause = e.getCause();
propagateIfPossible(cause, QueryPreprocessorException.class);
throw new QueryPreprocessorException("Error preprocessing query: " + cause.getMessage(), cause);
}
catch (TimeoutException e) {
throw new QueryPreprocessorException("Timed out waiting for query preprocessor after " + timeout);
}
finally {
Process process = processReference.get();
if (process != null) {
process.destroyForcibly();
}
task.cancel(true);
}
}
private static <T> Future<T> executeInNewThread(String threadName, Callable<T> callable)
{
FutureTask<T> task = new FutureTask<>(callable);
Thread thread = new Thread(task);
thread.setName(threadName);
thread.setDaemon(true);
thread.start();
return task;View on GitHub (pinned to 55bb57d202)
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.
Example fix
// before ./presto --server ... --preprocessor-command ./slow-preprocessor.sh # hangs > timeout // after timeout 5 ./slow-preprocessor.sh # self-limiting; also raise CLI preprocessor timeout
Defensive patterns
Strategy: try-catch
Validate before calling
# bound the preprocessor's own runtime timeout 10s your-preprocessor.sh < sample.sql && echo OK
Try / catch
try {
preprocessQuery(query);
} catch (QueryPreprocessorException e) {
if (e.getMessage().startsWith("Timed out waiting for query preprocessor")) {
log.error("preprocessor exceeded timeout; increase timeout or speed up the command");
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Error preprocessing query:
- Query preprocessor exited
- ATOP_READ_TIMEOUT
- both --execute and --file specified
- Error reading from file %s: %s
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/65a258d27fd41819.
Report an issue: GitHub.