{"record":{"id":"5d97c2f18df88c4a","repo":"prestodb/presto","slug":"server-shutting-down-5d97c2","errorCode":"SERVER_SHUTTING_DOWN","errorMessage":"Server is shutting down","messagePattern":"Server is shutting down","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"warning","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/StateMachine.java","lineNumber":316,"sourceCode":"    public interface StateChangeListener<T>\n    {\n        void stateChanged(T newState);\n    }\n\n    @Override\n    public String toString()\n    {\n        return get().toString();\n    }\n\n    private void safeExecute(Runnable command)\n    {\n        try {\n            executor.execute(command);\n        }\n        catch (RejectedExecutionException e) {\n            if ((executor instanceof ExecutorService) && ((ExecutorService) executor).isShutdown()) {\n                throw new PrestoException(SERVER_SHUTTING_DOWN, \"Server is shutting down\", e);\n            }\n            throw e;\n        }\n    }\n}\n","sourceCodeStart":298,"sourceCodeEnd":322,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/StateMachine.java#L298-L322","documentation":"The query state machine's executor rejected a state-change callback because the executor service was shut down — i.e. the Presto server is shutting down. It is surfaced as SERVER_SHUTTING_DOWN so clients know the failure is server-side and transient.","triggerScenarios":"safeExecute() calls executor.execute(command) during a query state transition and receives RejectedExecutionException with executor.isShutdown() == true — queries transitioning while the coordinator is stopping.","commonSituations":"Queries running/coordinating during a coordinator restart, rolling deployments, or graceful shutdown killing the executor while queries are still active.","solutions":["Retry the query after the server finishes restarting.","Wait for the coordinator to come back healthy (health check) before resubmitting.","During planned shutdowns, drain/cancel active queries first.","Use a load balancer to route clients away from shutting-down coordinators."],"exampleFix":"// before\nquery = client.execute(sql); // throws SERVER_SHUTTING_DOWN during restart\n// after\nretryOn(SERVER_SHUTTING_DOWN, backoff, () -> client.execute(sql));","handlingStrategy":"retry","validationCode":"// check server health before submitting queries\nGET /v1/status -> 200 means coordinator is up","typeGuard":null,"tryCatchPattern":"// catch PrestoException with errorCode SERVER_SHUTTING_DOWN; back off and retry after the coordinator restarts (bounded retries)","preventionTips":["Use health-checked load balancing across coordinators","Drain queries before planned restarts","Apply bounded exponential backoff for transient server errors"],"tags":["shutdown","server-lifecycle","transient"],"backgroundTag":"server-shutting-down","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"}