apache/hadoop · error · IOException
Expected to find <childrenSize> in <dirDiff> section.
Error message
Expected to find <childrenSize> in <dirDiff> section.
What it means
A <dirDiff> element is missing <childrenSize>, which the protobuf DirectoryDiff requires (it is a mandatory field, unlike the optional <snapshotId> and <name> read just before it). removeChildInt on the loaded dirDiff node returned null, so reconstruction aborts for this diff.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java:1463
try {
expectTag(SNAPSHOT_DIFF_SECTION_DIR_DIFF, false);
} catch (IOException e) {
throw new IOException("Only read " + (actualDiffs + 1) +
" diffs out of " + expectedDiffs, e);
}
Node dirDiff = new Node();
loadNodeChildren(dirDiff, "dirDiff fields");
FsImageProto.SnapshotDiffSection.DirectoryDiff.Builder bld =
FsImageProto.SnapshotDiffSection.DirectoryDiff.newBuilder();
Integer snapshotId = dirDiff.removeChildInt(
SNAPSHOT_DIFF_SECTION_SNAPSHOT_ID);
if (snapshotId != null) {
bld.setSnapshotId(snapshotId);
}
Integer childrenSize = dirDiff.removeChildInt(
SNAPSHOT_DIFF_SECTION_CHILDREN_SIZE);
if (childrenSize == null) {
throw new IOException("Expected to find <childrenSize> in " +
"<dirDiff> section.");
}
bld.setIsSnapshotRoot(dirDiff.removeChildBool(
SNAPSHOT_DIFF_SECTION_IS_SNAPSHOT_ROOT));
bld.setChildrenSize(childrenSize);
String name = dirDiff.removeChildStr(SECTION_NAME);
if (name != null) {
bld.setName(ByteString.copyFrom(name, StandardCharsets.UTF_8));
}
Node snapshotCopy = dirDiff.removeChild(
SNAPSHOT_DIFF_SECTION_SNAPSHOT_COPY);
if (snapshotCopy != null) {
bld.setSnapshotCopy(createINodeDirectoryBuilder(snapshotCopy));
}
Integer expectedCreatedListSize = dirDiff.removeChildInt(
SNAPSHOT_DIFF_SECTION_CREATED_LIST_SIZE);
if (expectedCreatedListSize == null) {
throw new IOException("Expected to find <createdListSize> in " +View on GitHub (pinned to 2add963021)
Solutions
- Add <childrenSize>N</childrenSize> to the affected <dirDiff> (the directory's children count in that snapshot; 0 is valid)
- Check spelling, case, and nesting - it must be a direct child of <dirDiff>
- Regenerate the XML from the original fsimage with a same-version oiv to recover the true values
- Pre-scan for <dirDiff> elements lacking required children before running ReverseXML
Example fix
<!-- before --> <dirDiff><snapshotId>3</snapshotId><name>snap1</name></dirDiff> <!-- after --> <dirDiff><snapshotId>3</snapshotId><childrenSize>0</childrenSize><name>snap1</name></dirDiff>
Defensive patterns
Strategy: validation
Validate before calling
# python: every <dirDiff> needs <childrenSize>
import xml.etree.ElementTree as ET
def dirdiffs_have_childrensize(path):
for ev, el in ET.iterparse(path, events=('end',)):
if el.tag == 'dirDiff' and el.find('childrenSize') is None:
return False
return True Try / catch
// oiv exit != 0 with 'Expected to find <childrenSize>' -> patch the named // <dirDiff>, delete partial output, retry
Prevention
- childrenSize is mandatory even when 0 - templates must include it
- Keep required fields direct children of <dirDiff>
- Pre-scan for required fields on every dirDiff
- Regenerate from the original image when values are unknown
When it happens
Trigger: A <dirDiff> hand-authored or trimmed without <childrenSize>, or the field renamed/misspelled (exact tag 'childrenSize' required); also fields accidentally nested inside <snapshotCopy> during restructuring.
Common situations: Hand-written diffs copied from a template that omitted the field; scripts emitting only the 'interesting' fields; XML from an older writer that predates the field.
Related errors
- <dirDiffEntry> contained no <inodeId> entry.
- <dirDiffEntry> contained no <count> entry.
- Expected to find <createdListSize> in <dirDiff> section.
- Expected <created> entry to have a <name> field
- <fileDiffEntry> contained no <inodeid> entry.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/83ce5ec72e075e6a.
Report an issue: GitHub.