{"record":{"id":"3be336dd7b34888b","repo":"apache/cassandra","slug":"timeout","errorCode":null,"errorMessage":"timeout","messagePattern":"timeout","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/SimpleClient.java","lineNumber":333,"sourceCode":"\n        // Shut down all thread pools to exit.\n        bootstrap.group().shutdownGracefully();\n    }\n\n    public Message.Response execute(Message.Request request)\n    {\n        return execute(request, true);\n    }\n\n    public Message.Response execute(Message.Request request, boolean throwOnErrorResponse)\n    {\n        try\n        {\n            request.attach(connection);\n            lastWriteFuture = channel.writeAndFlush(Collections.singletonList(request));\n            Message.Response msg = responseHandler.responses.poll(TIMEOUT_SECONDS, TimeUnit.SECONDS);\n            if (msg == null)\n                throw new RuntimeException(\"timeout\");\n            if (throwOnErrorResponse && msg instanceof ErrorMessage)\n                throw new RuntimeException((Throwable)((ErrorMessage)msg).error);\n            return msg;\n        }\n        catch (InterruptedException e)\n        {\n            throw new UncheckedInterruptedException(e);\n        }\n    }\n\n    public Map<Message.Request, Message.Response> execute(List<Message.Request> requests)\n    {\n        try\n        {\n            Map<Message.Request, Message.Response> rrMap = new HashMap<>();\n\n            if (version.isGreaterOrEqualTo(ProtocolVersion.V5))\n            {","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/SimpleClient.java#L315-L351","documentation":"SimpleClient.execute() writes a request frame and then waits up to TIMEOUT_SECONDS on the response queue; if no response arrives in that window it throws a plain RuntimeException(\"timeout\"). This is a synchronous client-side wait timeout, not necessarily a server-side query timeout — the response may have been lost, the server busy, or the write itself stalled.","triggerScenarios":"Calling execute()/execute(query, values, consistency) and Message.Response poll(TIMEOUT_SECONDS) returns null because the server did not answer within the fixed timeout.","commonSituations":"Heavy server load or long-running queries exceeding the client timeout; a dropped connection after the write (lastWriteFuture never completed); server GC pauses; using the simple test client against a production cluster under load.","solutions":["Check server health/logs for slow queries or GC pauses during the window.","Retry the request; SimpleClient has no built-in retry or speculative execution.","Increase TIMEOUT_SECONDS in SimpleClient if latency is legitimately high, or use the java driver which has configurable, per-request timeouts.","Verify the channel is still open (channel.isActive()) before writing; reconnect on failure."],"exampleFix":"// before\nMessage.Response resp = client.execute(\"SELECT * FROM t\", ConsistencyLevel.ONE);\n// after\ntry {\n    Message.Response resp = client.execute(\"SELECT * FROM t\", ConsistencyLevel.ONE);\n} catch (RuntimeException e) {\n    if (\"timeout\".equals(e.getMessage())) { client.close(); client.connect(false); /* retry */ }\n}","handlingStrategy":"retry","validationCode":"// pre-flight\nif (!client.connection.channel().isActive()) { client.close(); client.connect(false); }","typeGuard":null,"tryCatchPattern":"try { return client.execute(query, cl); } catch (RuntimeException e) { if (\"timeout\".equals(e.getMessage())) { reconnect(); return retry(query, cl); } throw e; }","preventionTips":["Keep SimpleClient for tests only; use the java driver for real workloads","Monitor server GC pauses and slow-query logs","Retry idempotent requests on timeout"],"tags":["timeout","native-protocol","client","network"],"backgroundTag":"request-timeout","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}