{"record":{"id":"cb297c3b77d402c1","repo":"apache/cassandra","slug":"ran-out-of-time-returning-best-effort","errorCode":null,"errorMessage":"Ran out of time. Returning best effort.","messagePattern":"Ran out of time\\. Returning best effort\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/db/virtual/AbstractLazyVirtualTable.java","lineNumber":766,"sourceCode":"    public UnfilteredPartitionIterator select(DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits)\n    {\n        return select(new DataRange(new Bounds<>(partitionKey, partitionKey), clusteringIndexFilter), columnFilter, rowFilter, limits);\n    }\n\n    @Override\n    public final UnfilteredPartitionIterator select(DataRange dataRange, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits)\n    {\n        PartitionsCollector collector = collector(dataRange, columnFilter, rowFilter, limits);\n        try\n        {\n            collect(collector);\n        }\n        catch (InternalDoneException ignore) {}\n        catch (InternalTimeoutException ignore)\n        {\n            if (onTimeout != OnTimeout.BEST_EFFORT || collector.isEmpty())\n                throw new ReadTimeoutException(ONE, 0, 1, false);\n            ClientWarn.instance.warn(\"Ran out of time. Returning best effort.\");\n        }\n        return collector.finish();\n    }\n\n    @Override\n    public void apply(PartitionUpdate update)\n    {\n        throw new InvalidRequestException(\"Modification is not supported by table \" + metadata);\n    }\n\n    @Override\n    public void truncate()\n    {\n        throw new InvalidRequestException(\"Truncation is not supported by table \" + metadata);\n    }\n\n    @Override\n    public String toString()","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/virtual/AbstractLazyVirtualTable.java#L748-L784","documentation":"When a virtual table query runs against a soft deadline and the time budget is exhausted, AbstractLazyVirtualTable either throws ReadTimeoutException (if no partial rows were collected or best-effort is off) or, in best-effort mode with partial results, emits the client warning 'Ran out of time. Returning best effort.' and returns the partial data set. It exists so slow virtual tables do not stall coordinator threads indefinitely.","triggerScenarios":"SELECT from a lazy virtual table (e.g. system_views sessions/logs-style tables) whose producer takes longer than the configured deadline while OnTimeout.BEST_EFFORT is set and the collector already has rows; a correlated throw of InternalTimeoutException from a per-row/remote fetch lands in this catch block.","commonSituations":"Querying large virtual tables on busy nodes; slow remote-node collectors feeding a virtual table; users paging through virtual tables with no LIMIT; tight virtual-table timeouts on loaded clusters.","solutions":["Add a LIMIT clause or narrower WHERE filter to reduce how much of the virtual table is scanned.","Re-run the query; retry after the node is less loaded so the deadline is met.","Raise the relevant timeout configuration (e.g. read/request timeouts) if virtual table queries legitimately need more time.","Treat the returned rows as incomplete; check ClientWarn warnings in your driver before relying on the result."],"exampleFix":"// before: full scan, may return partial data\nSELECT * FROM system_views.recent_messages;\n\n// after: bounded query completes within the deadline\nSELECT * FROM system_views.recent_messages LIMIT 100;","handlingStrategy":"fallback","validationCode":"// check for the partial-result warning after querying a virtual table\nRow row = session.execute(\"SELECT * FROM system_views.some_table LIMIT 100\").getExecutionInfo().getWarnings()\n    .stream().filter(w -> w.contains(\"Ran out of time\")).findFirst().orElse(null);\nif (row != null) { /* treat result as incomplete */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use LIMIT/narrow filters on virtual tables.","Inspect driver warnings (getWarnings) before consuming virtual-table results.","Query virtual tables during low-load windows."],"tags":["virtual-table","timeout","best-effort","partial-results"],"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"}