{"record":{"id":"e8866c451cf96917","repo":"prestodb/presto","slug":"query-is-gone-server-restarted","errorCode":null,"errorMessage":"Query is gone (server restarted?)","messagePattern":"Query is gone \\(server restarted\\?\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/PlanCheckerRouterPluginPrestoClient.java","lineNumber":104,"sourceCode":"        boolean isNativeCompatible = true;\n        // submit initial query\n        try (StatementClient client = newStatementClient(httpClient, clientSession, newSql)) {\n            // read query output\n            while (client.isRunning()) {\n                log.debug((client.currentData().toString()));\n\n                if (!client.advance()) {\n                    break;\n                }\n            }\n\n            // verify final state\n            if (client.isClientAborted()) {\n                throw new IllegalStateException(\"Query aborted by user\");\n            }\n\n            if (client.isClientError()) {\n                throw new IllegalStateException(\"Query is gone (server restarted?)\");\n            }\n\n            verify(client.isFinished());\n            QueryError resultsError = client.finalStatusInfo().getError();\n            if (resultsError != null) {\n                isNativeCompatible = false;\n                log.info(resultsError.getMessage());\n            }\n        }\n        catch (Exception e) {\n            if (javaClusterFallbackEnabled) {\n                // If any exception is thrown, log the message and re-route to a Java clusters router.\n                isNativeCompatible = false;\n                log.info(e.getMessage());\n                fallBackToJavaClusterRedirectRequests.update(1L);\n            }\n            else {\n                // hard failure","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-plan-checker-router-plugin/src/main/java/com/facebook/presto/router/scheduler/PlanCheckerRouterPluginPrestoClient.java#L86-L122","documentation":"In the plan-checker router plugin, the internal Presto client that runs the native-compatibility verification query reports a client-side error state. The scheduler treats this as evidence the query no longer exists on the coordinator it was submitted to, typically because that coordinator restarted and lost the in-memory query, so the compatibility check cannot complete.","triggerScenarios":"getCompatibleClusterURI submits a query via the internal client; the client later reports isClientError() at the final-state verification, e.g. the target coordinator restarted or failed over between submit and fetch, or the query was dropped/expired server-side.","commonSituations":"Rolling restarts of Presto coordinators behind the router; a coordinator crash mid-query; submitting to a cluster that reaped the query before the client polled final status.","solutions":["Retry the compatibility probe against the same or another cluster after the coordinator comes back healthy","Check coordinator logs around the restart to confirm the query was lost and fix the underlying crash/OOM","Make the router prefer clusters with stable coordinators or add health checks before probing","Update the router to distinguish 'query gone due to restart' from genuine client errors and treat it as retryable"],"exampleFix":"// before\nif (client.isClientError()) {\n    throw new IllegalStateException(\"Query is gone (server restarted?)\");\n}\n// after\nif (client.isClientError()) {\n    if (retryCount < MAX_RETRIES) {\n        return getCompatibleClusterURI(query, retryCount + 1); // coordinator restarted; resubmit\n    }\n    throw new IllegalStateException(\"Query is gone (server restarted?)\");\n}","handlingStrategy":"retry","validationCode":"// before probing, verify the target coordinator is reachable and healthy\n// curl -s http://coordinator:8080/v1/status | jq -s 'length > 0'","typeGuard":null,"tryCatchPattern":"try {\n    URI cluster = getCompatibleClusterURI(query);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Query is gone\")) {\n        // coordinator restarted: retry or fail over to another cluster\n    } else {\n        throw e;\n    }\n}","preventionTips":["Add coordinator health checks before submitting probe queries","Treat client-error-on-final-state as retryable with bounded retries","Monitor coordinator restarts and route away from flapping coordinators"],"tags":["presto","router","query-lifecycle","retry"],"backgroundTag":"query-not-found-after-coordinator-restart","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"}