apache/hadoop · error · IOException
bytes array length error. Actual length is {}
Error message
bytes array length error. Actual length is {} What it means
In LevelDB mode, the value stored for each directory child in dirChildMap is the 8-byte parent inode id; this decode found a different length. The map is built in-process from the fsimage moments earlier, so a wrong length means the LevelDB store itself got corrupted mid-run (failing disk, another process touching the temp dir) — it is not caused by oiv arguments or the fsimage content.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/PBImageTextWriter.java:455
dirChildMap.put(toBytes(childId), toBytes(parentId));
}
@Override
public void putDir(INode dir) throws IOException {
Preconditions.checkArgument(dir.hasDirectory(),
"INode %s (%s) is not a directory.", dir.getId(), dir.getName());
dirMap.put(toBytes(dir.getId()), toBytes(dir.getName().toStringUtf8()));
}
private long getFromDirChildMap(long inode) throws IOException {
byte[] bytes = dirChildMap.get(toBytes(inode));
if (bytes == null) {
// The inode is an INodeReference, which is generated from snapshot.
// For delimited oiv tool, no need to print out metadata in snapshots.
throw PBImageTextWriter.createIgnoredSnapshotException(inode);
}
if (bytes.length != 8) {
throw new IOException(
"bytes array length error. Actual length is " + bytes.length);
}
return toLong(bytes);
}
@Override
public String getParentPath(long inode) throws IOException {
if (inode == INodeId.ROOT_INODE_ID) {
return "/";
}
long parent = getFromDirChildMap(inode);
byte[] bytes = dirMap.get(toBytes(parent));
synchronized (this) {
if (!dirPathCache.containsKey(parent)) {
if (parent != INodeId.ROOT_INODE_ID && bytes == null) {
// The parent is an INodeReference, which is generated from snapshot.
// For delimited oiv tool, no need to print out metadata in snapshots.
throw PBImageTextWriter.createIgnoredSnapshotException(inode);View on GitHub (pinned to 2add963021)
Solutions
- Rerun with a brand-new -t directory (delete the old one first)
- Rerun without -t to keep the metadata map in memory; this isolates the temp storage as the culprit
- If it reproduces deterministically with a fresh dir and the same fsimage, verify the fsimage md5 and file a HADOOP JIRA for PBImageTextWriter
Defensive patterns
Strategy: retry
Try / catch
try {
// oiv run with -t
} catch (IOException e) {
if (e.getMessage().contains("bytes array length error")) {
// internal LevelDB corruption: wipe temp dir and retry once, in memory if possible
FileUtils.deleteQuietly(new File(tempPath));
// rerun oiv without -t (or with a fresh -t)
} else {
throw e;
}
} Prevention
- Use a fresh -t directory for every run and delete it afterwards
- Put the temp dir on healthy local disk, not NFS or a flaky mount
- Do not touch files inside the live -t directory while oiv is running
When it happens
Trigger: Corruption of the LevelDB files under the -t directory while oiv is running: failing disk, another process writing into the live temp dir, or filesystem-level data damage on local or NFS-backed temp storage.
Common situations: Flaky local/NFS temp storage; operators clearing or copying files inside the live temp directory; very large images where long run times increase exposure.
Related errors
- Folder {} already exists! Delete manually or provide another
- Expected to parse {} in parallel, but parsed {}. The image m
- InMemoryAliasMap location is null
- Unable to create aliasmap snapshot directory {newLevelDBDir}
- File " + url + " computed digest " + computedDigest + " does
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/aae9a4fdbe11f625.
Report an issue: GitHub.