{"record":{"id":"4a6d24f3f193d986","repo":"apache/cassandra","slug":"corrupt-hint-file-found","errorCode":null,"errorMessage":"Corrupt hint file found","messagePattern":"Corrupt hint file found","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/hints/HintsReader.java","lineNumber":222,"sourceCode":"                }\n            }\n            while (hint == null);\n\n            return hint;\n        }\n\n        private Hint computeNextInternal() throws IOException\n        {\n            input.resetCrc();\n            input.resetLimit();\n\n            int size = input.readInt();\n            if (size == 0)\n            {\n                // Avoid throwing IOException when a hint file ends with a run of zeros - this\n                // can happen when hard-rebooting unresponsive machines.\n                if (!verifyAllZeros(input))\n                    throw new IOException(\"Corrupt hint file found\");\n                throw new EOFException(\"Unexpected end of file (size == 0)\");\n            }\n\n            // if we cannot corroborate the size via crc, then we cannot safely skip this hint\n            if (!input.checkCrc())\n                throw new IOException(\"Digest mismatch exception\");\n\n            return readHint(size);\n        }\n\n        private Hint readHint(int size) throws IOException\n        {\n            applyThrottleRateLimit(size);\n            input.limit(size);\n\n            Hint hint;\n            try\n            {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/hints/HintsReader.java#L204-L240","documentation":"HintsReader's iterator (computeNextInternal) throws IOException(\"Corrupt hint file found\") when it reads a zero entry size but verifyAllZeros shows the rest of the file is NOT all zeros. A size of 0 is tolerated only as trailing zero padding produced by hard-rebooting machines; zeros mixed with non-zero garbage mean real corruption, and reading is aborted.","triggerScenarios":"Reading a hints file after a hard reboot/power loss where the file was extended with zero pages but later regions contain stale non-zero data; disk corruption in the tail of a hints file; a partially overwritten hints file.","commonSituations":"Datacenter power loss or VM hard-kill; hints on filesystems without proper fsync behavior; faulty disks; manually manipulating hints files.","solutions":["Remove/quarantine the corrupt hints file from the hints directory and restart hint delivery.","Check disk/filesystem health (fsck, SMART) — recurring occurrences indicate hardware issues.","Run repair on affected ranges so missed hint deliveries are replaced by anti-entropy repair.","Preserve the file for support/debugging before deleting if the corruption is unexpected."],"exampleFix":"// before\nHint hint = hintsReader.iterator().next(); // IOException: Corrupt hint file found\n// after\ntry (HintsReader reader = HintsReader.open(file))\n{\n    for (Hint hint : reader)\n        deliver(hint);\n}\ncatch (IOException e)\n{\n    logger.warn(\"Corrupt hints file {}, skipping\", file, e);\n}","handlingStrategy":"try-catch","validationCode":"// detect a suspicious file before opening: all-zero tail vs mixed garbage requires stream check, so at minimum verify size is a multiple of plausible entry granularity\nif (!Files.isRegularFile(file) || Files.size(file) == 0) skipFile(file);","typeGuard":null,"tryCatchPattern":"try { for (Hint h : HintsReader.open(file)) deliver(h); } catch (IOException e) { logger.warn(\"Corrupt hints file {}\", file, e); archiveAndSkip(file); }","preventionTips":["Use UPS/clean shutdown procedures to avoid hard reboots that leave zero-padded tails.","Run filesystem journaling/fsck regularly; corrupt tails signal storage trouble.","Run periodic repair so hints lost to corruption do not mean data loss.","Alert on HintsReader IOExceptions to catch corruption early."],"tags":["java","hints","corruption","io"],"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"}