apache/hadoop · error · IOException

unknown DiffEntry type

Error message

unknown DiffEntry type {}

What it means

While dumping the SNAPSHOT_DIFF section to XML, a DiffEntry message carried a type other than FILEDIFF or DIRECTORYDIFF. Protobuf round-trips unknown enum numbers, so this happens when the image contains a DiffEntry type added in a Hadoop newer than this oiv build's generated protobufs — or, less likely, bit corruption decoding to an out-of-range type value.

Solutions

  1. Use an oiv build at least as new as the cluster that took the snapshots
  2. Verify the image md5 to rule out in-section corruption
  3. If versions cannot be aligned and snapshots are not needed, file a HADOOP JIRA with the type value shown in the message
Defensive patterns

Strategy: try-catch

Try / catch

try {
  new PBImageXmlWriter(conf, out).visit(file);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("unknown DiffEntry type")) {
    // newer protobuf enum value than this build knows: align tool version
    LOG.error("snapshot diff type unknown to this oiv build: {}", e.getMessage());
  }
  throw e;
}

Prevention

When it happens

Trigger: `hdfs oiv -p XML` on an image from a newer Hadoop that introduced a new snapshot diff entry kind; corrupted bytes inside the snapshot diff section.

Common situations: Snapshotted namespaces read with old tooling after a cluster upgrade.

Related errors


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

Appendix: source

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

  }

  private void dumpSnapshotDiffSection(InputStream in) throws IOException {
    out.print("<" + SNAPSHOT_DIFF_SECTION_NAME + ">");
    while (true) {
      SnapshotDiffSection.DiffEntry e = SnapshotDiffSection.DiffEntry
          .parseDelimitedFrom(in);
      if (e == null) {
        break;
      }
      switch (e.getType()) {
      case FILEDIFF:
        out.print("<" + SNAPSHOT_DIFF_SECTION_FILE_DIFF_ENTRY + ">");
        break;
      case DIRECTORYDIFF:
        out.print("<" + SNAPSHOT_DIFF_SECTION_DIR_DIFF_ENTRY + ">");
        break;
      default:
        throw new IOException("unknown DiffEntry type " + e.getType());
      }
      o(SNAPSHOT_DIFF_SECTION_INODE_ID, e.getInodeId());
      o(SNAPSHOT_DIFF_SECTION_COUNT, e.getNumOfDiff());
      switch (e.getType()) {
      case FILEDIFF: {
        for (int i = 0; i < e.getNumOfDiff(); ++i) {
          out.print("<" + SNAPSHOT_DIFF_SECTION_FILE_DIFF + ">");
          SnapshotDiffSection.FileDiff f = SnapshotDiffSection.FileDiff
              .parseDelimitedFrom(in);
          o(SNAPSHOT_DIFF_SECTION_SNAPSHOT_ID, f.getSnapshotId())
              .o(SNAPSHOT_DIFF_SECTION_SIZE, f.getFileSize())
              .o(SECTION_NAME, f.getName().toStringUtf8());
          INodeSection.INodeFile snapshotCopy = f.getSnapshotCopy();
          if (snapshotCopy != null) {
            out.print("<" + SNAPSHOT_DIFF_SECTION_SNAPSHOT_COPY + ">");
            dumpINodeFile(snapshotCopy);
            out.print("</" + SNAPSHOT_DIFF_SECTION_SNAPSHOT_COPY + ">\n");
          }

View on GitHub (pinned to 2add963021)