{"record":{"id":"07e9a8b17107bc08","repo":"prestodb/presto","slug":"interrupted-while-preprocessing-query","errorCode":null,"errorMessage":"Interrupted while preprocessing query","messagePattern":"Interrupted while preprocessing query","errorType":"exception","errorClass":"QueryPreprocessorException","httpStatus":null,"severity":"warning","filePath":"presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java","lineNumber":163,"sourceCode":"                        throw e.getCause();\n                    }\n\n                    // wait for process to finish\n                    exitCode = process.waitFor();\n                }\n                finally {\n                    process.destroyForcibly();\n                    if (writeOutput != null) {\n                        writeOutput.cancel(true);\n                    }\n                }\n            }\n            catch (QueryPreprocessorException e) {\n                throw e;\n            }\n            catch (InterruptedException e) {\n                Thread.currentThread().interrupt();\n                throw new QueryPreprocessorException(\"Interrupted while preprocessing query\");\n            }\n            catch (Throwable e) {\n                throw new QueryPreprocessorException(\"Error preprocessing query: \" + e.getMessage(), e);\n            }\n\n            // check we got a valid exit code\n            if (exitCode != 0) {\n                Optional<String> errorMessage = tryGetFutureValue(readStderr, 100, MILLISECONDS)\n                        .flatMap(value -> Optional.ofNullable(emptyToNull(value.trim())));\n\n                throw new QueryPreprocessorException(\"Query preprocessor exited \" + exitCode +\n                        errorMessage.map(message1 -> \"\\n===\\n\" + message1 + \"\\n===\").orElse(\"\"));\n            }\n            return result;\n        });\n\n        try {\n            return task.get(timeout.toMillis(), MILLISECONDS);","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-cli/src/main/java/com/facebook/presto/cli/QueryPreprocessor.java#L145-L181","documentation":"QueryPreprocessor.preprocessQueryInternal catches InterruptedException while preparing the query and rethrows it as QueryPreprocessorException('Interrupted while preprocessing query') after restoring the interrupt flag. This happens when the thread running query preprocessing (e.g. the CLI's exit hook or session setup) is interrupted during shutdown.","triggerScenarios":"The thread executing preprocessQuery is interrupted — typically Ctrl-C / SIGINT terminating the CLI while the query is still being preprocessed, or a timeout cancelling the thread.","commonSituations":"User cancels a hanging presto session during startup; orchestration kills the CLI mid-preprocessing; long-running --file preprocessing interrupted by a shell timeout.","solutions":["This usually indicates intentional cancellation — rerun the query once the interruption cause is removed","Avoid sending SIGINT/timeout before preprocessing completes; raise shell timeout values","If it appears unexpectedly, check for other code interrupting shared threads and ensure the interrupt flag is honored for clean shutdown"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { preprocess(query); } catch (QueryPreprocessorException e) { if (\"Interrupted while preprocessing query\".equals(e.getMessage())) { /* deliberate cancel: exit cleanly, don't rethrow as failure */ } else throw e; }","preventionTips":["Avoid killing CLI processes during startup/preprocessing","Configure generous shell/CI timeouts","Handle SIGINT gracefully and let the interrupt flag propagate"],"tags":["interruption","cli","shutdown"],"backgroundTag":"thread-interrupted","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"}