{"record":{"id":"89ffc3d31e8a72e9","repo":"apache/hadoop","slug":"first-node-is-not-root","errorCode":null,"errorMessage":"First node is not root","messagePattern":"First node is not root","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java","lineNumber":526,"sourceCode":"     while (numFiles > 0) {\n       numFiles -= loadDirectory(in, counter);\n     }\n     if (numFiles != 0) {\n       throw new IOException(\"Read unexpect number of files: \" + -numFiles);\n     }\n   }\n   \n    /**\n     * Load information about root, and use the information to update the root\n     * directory of NameSystem.\n     * @param in The {@link DataInput} instance to read.\n     * @param counter Counter to increment for namenode startup progress\n     */\n    private void loadRoot(DataInput in, Counter counter)\n        throws IOException {\n      // load root\n      if (in.readShort() != 0) {\n        throw new IOException(\"First node is not root\");\n      }\n      final INodeDirectory root = loadINode(null, false, in, counter)\n        .asDirectory();\n      // update the root's attributes\n      updateRootAttr(root);\n    }\n   \n    /** Load children nodes for the parent directory. */\n    private int loadChildren(INodeDirectory parent, DataInput in,\n        Counter counter) throws IOException {\n      int numChildren = in.readInt();\n      for (int i = 0; i < numChildren; i++) {\n        // load single inode\n        INode newNode = loadINodeWithLocalName(false, in, true, counter);\n        addToParent(parent, newNode);\n      }\n      return numChildren;\n    }","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java#L508-L544","documentation":"Error \"First node is not root\" thrown in apache/hadoop.","triggerScenarios":"Loading an old-format fsimage whose first inode entry is not the root directory, indicating a corrupt image.","commonSituations":"See trigger scenarios.","solutions":["The fsimage is corrupt (root inode missing); restore the image from a backup or another NameNode storage directory."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}