{"record":{"id":"b508bf6addd22a7d","repo":"apache/cassandra","slug":"failed-to-read-log-entries","errorCode":null,"errorMessage":"Failed to read log entries","messagePattern":"Failed to read log entries","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/OfflineClusterMetadataDump.java","lineNumber":434,"sourceCode":"                                        \" exceeds max available epoch \" + maxAvailableEpoch);\n                    }\n                }\n\n                // Warn if there's a gap between snapshot and first entry\n                ClusterMetadata effectiveBase = base;\n                if (effectiveBase != null && !entryList.isEmpty() && !entryList.get(0).epoch.isDirectlyAfter(effectiveBase.epoch))\n                {\n                    out.err.println(\"WARNING: Gap between snapshot (epoch \" + effectiveBase.epoch.getEpoch() +\n                                    \") and first log entry (epoch \" + entryList.get(0).epoch.getEpoch() +\n                                    \"). Proceeding without base snapshot.\");\n                    effectiveBase = null;\n                }\n\n                return new LogState(effectiveBase, entryList);\n            }\n            catch (IOException e)\n            {\n                throw new RuntimeException(\"Failed to read log entries\", e);\n            }\n        }\n\n        static private Epoch previousEpoch(Epoch epoch)\n        {\n            if (UPGRADE_GOSSIP.equals(epoch) || UPGRADE_STARTUP.equals(epoch))\n                return epoch;\n            if (EMPTY.equals(epoch) || FIRST.equals(epoch))\n                return EMPTY;\n            return Epoch.create(epoch.getEpoch() - 1);\n        }\n\n        /**\n         * Validates that the from-epoch is not greater than to-epoch.\n         */\n        protected void validateEpochRange(Long fromEpoch, Long toEpoch)\n        {\n            if (fromEpoch != null && toEpoch != null && fromEpoch > toEpoch)","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/OfflineClusterMetadataDump.java#L416-L452","documentation":"OfflineClusterMetadataDump reads ClusterMetadata log segment files from disk without a running cluster. If any IOException occurs while iterating/reading log entries to build a LogState, getLogState wraps it in a RuntimeException with this message and the original exception as cause.","triggerScenarios":"Calling the offline metadata dump tool when the metadata log segment files are missing, unreadable (permissions), truncated, or on a filesystem error; also on disk I/O failures while scanning the commit log/metadata log directory.","commonSituations":"Pointing the tool at the wrong data directory so log files are absent; copying data dirs without the metadata log segments; running as a user without read permission on the files; corrupted/truncated segments after a crash.","solutions":["Check the cause in the stack trace and fix the underlying I/O problem (missing file, permissions)","Run the tool against the correct node data directory containing the metadata log segments","Verify file read permissions for the user running the tool","Restore the missing/corrupt segments from a healthy replica or backup"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"File dir = new File(dataDir);\nif (!dir.isDirectory() || !dir.canRead()) throw new IllegalStateException(\"Cannot read log dir: \" + dataDir);","typeGuard":null,"tryCatchPattern":"try { LogState s = dump.getLogState(...); }\ncatch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) LOG.error(\"log read failed: \" + e.getCause(), e);\n    throw e;\n}","preventionTips":["Point the tool at the correct node data directory containing the metadata log segments","Run as a user with read permission on the segment files","Restore missing/corrupt segments before running offline tools"],"tags":["offline-tools","io-exception","file-read","cassandra"],"backgroundTag":"file-read-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}