{"record":{"id":"e45946dcb8c15529","repo":"apache/hadoop","slug":"checksum-file-not-a-length-multiple-of-checksum-si-e45946","errorCode":null,"errorMessage":"Checksum file not a length multiple of checksum size in {} at {} checksumpos: {} sumLenread: {}","messagePattern":"Checksum file not a length multiple of checksum size in (.+?) at (.+?) checksumpos: (.+?) sumLenread: (.+?)","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"critical","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFs.java","lineNumber":248,"sourceCode":"    protected int readChunk(long pos, byte[] buf, int offset, int len,\n        byte[] checksum) throws IOException {\n      boolean eof = false;\n      if (needChecksum()) {\n        assert checksum != null; // we have a checksum buffer\n        assert checksum.length % CHECKSUM_SIZE == 0; // it is sane length\n        assert len >= bytesPerSum; // we must read at least one chunk\n\n        final int checksumsToRead = Math.min(\n          len/bytesPerSum, // number of checksums based on len to read\n          checksum.length / CHECKSUM_SIZE); // size of checksum buffer\n        long checksumPos = getChecksumFilePos(pos); \n        if(checksumPos != sums.getPos()) {\n          sums.seek(checksumPos);\n        }\n\n        int sumLenRead = sums.read(checksum, 0, CHECKSUM_SIZE * checksumsToRead);\n        if (sumLenRead >= 0 && sumLenRead % CHECKSUM_SIZE != 0) {\n          throw new EOFException(\"Checksum file not a length multiple of checksum size \" +\n                                 \"in \" + file + \" at \" + pos + \" checksumpos: \" + checksumPos +\n                                 \" sumLenread: \" + sumLenRead );\n        }\n        if (sumLenRead <= 0) { // we're at the end of the file\n          eof = true;\n        } else {\n          // Adjust amount of data to read based on how many checksum chunks we read\n          len = Math.min(len, bytesPerSum * (sumLenRead / CHECKSUM_SIZE));\n        }\n      }\n      if (pos != datas.getPos()) {\n        datas.seek(pos);\n      }\n      int nread = readFully(datas, buf, offset, len);\n      if (eof && nread > 0) {\n        throw new ChecksumException(\"Checksum error: \"+file+\" at \"+pos, pos);\n      }\n      return nread;","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFs.java#L230-L266","documentation":"While reading a file through ChecksumFs (FileContext's checksummed local fs), the code read N bytes from the sidecar .crc checksum file where N is not a multiple of 4 (the CRC entry size). A well-formed .crc is a header plus a whole number of 4-byte checksums, so this means the checksum file itself is truncated or malformed - corruption of the metadata, not the data.","triggerScenarios":"Reading via FileContext/ChecksumFs when the .crc sidecar was truncated: the file pair was copied without the .crc being fully copied (cp of data file only partially), a disk-full event cut an earlier write short, or a non-Hadoop tool generated a bogus .crc. The exception fires in read() once the reader reaches the region whose checksums it must fetch.","commonSituations":"Data directories copied or rsync'd between nodes with hidden .crc files mishandled; interrupted write (kill -9 during create, full disk) leaving data file and .crc inconsistent; a previous raw-fs append/truncate (the unsupported-operation bypass) leaving a .crc whose length no longer matches the data.","solutions":["Delete the stale sidecar checksum file (for a local path /p/f it is /p/.f.crc); readers then proceed without verification and the next create regenerates it.","Triage with checksums disabled: fc.setVerifyChecksum(false) then read the data - if the read succeeds the data is fine and only the .crc is bad.","Restore the file and its .crc together from your backup/replica.","If it recurs, check the volume with badblocks/smartctl - a repeatedly truncating .crc points at failing storage."],"exampleFix":"// before\nFSDataInputStream in = fc.open(path); // later read() throws EOFException:\n// Checksum file not a length multiple of checksum size in /data/f at ... \n\n// after: drop the malformed sidecar, then read unverified\njava.nio.file.Path crc = java.nio.file.Paths.get(\"/data/\", \".f.crc\");\njava.nio.file.Files.deleteIfExists(crc);\nFSDataInputStream in = fc.open(path);","handlingStrategy":"try-catch","validationCode":"java.nio.file.Path crc = dir.resolve(\".\" + fileName + \".crc\");\nif (java.nio.file.Files.exists(crc) && java.nio.file.Files.size(crc) % 4 != 0) {\n  // malformed sidecar: delete or quarantine it before reading\n}","typeGuard":null,"tryCatchPattern":"try {\n  in = fc.open(path);\n  in.read(buf);\n} catch (EOFException e) { // 'Checksum file not a length multiple...'\n  // sidecar is corrupt: disable verification or delete the .crc and retry\n}","preventionTips":["Always copy local Hadoop data with its hidden .crc files (rsync -a, cp -p), or delete all .crc files at once.","Never edit data files in place outside the checksummed fs API.","After any raw-fs append/truncate, remove the corresponding .crc."],"tags":["hadoop","filesystem","checksum","data-corruption","crc","local-filesystem"],"backgroundTag":"checksum-file-corruption","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}