apache/hadoop · error · IOException

The <version> section doesn't contain the layoutVersion.

Error message

The <version> section doesn't contain the layoutVersion.

What it means

The <version> section contains no <layoutVersion> child, which must equal the NameNode layout version the reconstructed image claims and is written into FileSummary.layoutVersion. Its absence makes the version block incomplete and reconstruction aborts immediately after the onDiskVersion check.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java:1697

    } catch (IOException e) {
      // Handle the case where <version> does not exist.
      // Note: fsimage XML files which are missing <version> are also missing
      // many other fields that oiv needs to accurately reconstruct the
      // fsimage.
      throw new IOException("No <version> section found at the top of " +
          "the fsimage XML.  This XML file is too old to be processed " +
          "by oiv.", e);
    }
    Node version = new Node();
    loadNodeChildren(version, "version fields");
    Integer onDiskVersion = version.removeChildInt("onDiskVersion");
    if (onDiskVersion == null) {
      throw new IOException("The <version> section doesn't contain " +
          "the onDiskVersion.");
    }
    Integer layoutVersion = version.removeChildInt("layoutVersion");
    if (layoutVersion == null) {
      throw new IOException("The <version> section doesn't contain " +
          "the layoutVersion.");
    }
    if (layoutVersion.intValue() !=
        NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION) {
      throw new IOException("Layout version mismatch.  This oiv tool " +
          "handles layout version " +
          NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION + ", but the " +
          "XML file has <layoutVersion> " + layoutVersion + ".  Please " +
          "either re-generate the XML file with the proper layout version, " +
          "or manually edit the XML file to be usable with this version " +
          "of the oiv tool.");
    }
    fileSummaryBld.setOndiskVersion(onDiskVersion);
    fileSummaryBld.setLayoutVersion(layoutVersion);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Loaded <version> with onDiskVersion=" + onDiskVersion +
          ", layoutVersion=" + layoutVersion + ".");
    }

View on GitHub (pinned to 2add963021)

Solutions

  1. Add <layoutVersion>N</layoutVersion> inside <version>, where N must equal this oiv's NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION (a negative number, e.g. -66)
  2. Copy the exact <version> block from an XML dump produced by the same Hadoop build you reconstruct with
  3. Validate the version block with a pre-check script
  4. Regenerate the XML from the original binary fsimage

Example fix

<!-- before -->
<version><onDiskVersion>1</onDiskVersion></version>
<!-- after -->
<version><onDiskVersion>1</onDiskVersion><layoutVersion>-66</layoutVersion></version>
Defensive patterns

Strategy: validation

Validate before calling

# python: <version> must contain <layoutVersion>
import xml.etree.ElementTree as ET

def version_block_ok(path):
    for ev, el in ET.iterparse(path, events=('end',)):
        if el.tag == 'version':
            return el.find('layoutVersion') is not None
    return False

Try / catch

// catch the missing-layoutVersion failure; restore the exact negative
// value this oiv build expects (see its NameNodeLayoutVersion), re-run

Prevention

When it happens

Trigger: A <version> element with <layoutVersion> omitted, renamed, or nested at the wrong level; hand-authored headers where only onDiskVersion was filled in.

Common situations: Incomplete hand-built or template-generated version blocks; field renaming during cleanup; XML from tooling that predates the field.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/fd317fabad1a70b9. Report an issue: GitHub.