{"record":{"id":"e6a64a5d467b37ff","repo":"apache/hadoop","slug":"could-not-create-directory-curdir","errorCode":null,"errorMessage":"Could not create directory ${curDir}","messagePattern":"Could not create directory (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java","lineNumber":1052,"sourceCode":"    void setMergeError() {\n      mergeErrorCount++;\n    }\n\n    void clearMergeError() {\n      mergeErrorCount = 0;\n    }\n \n    /**\n     * Ensure that the current/ directory exists in all storage\n     * directories\n     */\n    void ensureCurrentDirExists() throws IOException {\n      for (Iterator<StorageDirectory> it\n             = storage.dirIterator(); it.hasNext();) {\n        StorageDirectory sd = it.next();\n        File curDir = sd.getCurrentDir();\n        if (!curDir.exists() && !curDir.mkdirs()) {\n          throw new IOException(\"Could not create directory \" + curDir);\n        }\n      }\n    }\n\n    void deleteTempEdits() throws IOException {\n      FilenameFilter filter = new FilenameFilter() {\n        @Override\n        public boolean accept(File dir, String name) {\n          return name.matches(NameNodeFile.EDITS_TMP.getName()\n              + \"_(\\\\d+)-(\\\\d+)_(\\\\d+)\");\n        }\n      };\n      Iterator<StorageDirectory> it = storage.dirIterator(NameNodeDirType.EDITS);\n      for (;it.hasNext();) {\n        StorageDirectory dir = it.next();\n        File[] tempEdits = dir.getCurrentDir().listFiles(filter);\n        if (tempEdits != null) {\n          for (File t : tempEdits) {","sourceCodeStart":1034,"sourceCodeEnd":1070,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java#L1034-L1070","documentation":"SecondaryNameNode.ensureCurrentDirExists() verifies that the current/ subdirectory exists in every checkpoint storage directory before merging; if it does not exist and mkdirs() fails, an IOException with the concrete path is thrown and the checkpoint aborts. Unlike the startup checks, this fires mid-checkpoint when storage becomes unwritable between checkpoints.","triggerScenarios":"sd.getCurrentDir() returns <checkpoint.dir>/current which is absent, and File.mkdirs() returns false — parent not writable, disk full, read-only filesystem remount, or a plain file named 'current' already occupying the path.","commonSituations":"Checkpoint disk fills up or goes read-only (failing disk, NFS soft-mount trouble) while the 2NN keeps running; permissions changed after a security hardening pass; a partially formatted directory left over from a crashed run.","solutions":["Check free space and mount health on every checkpoint volume (df -h <dir>) and clear space or remount rw","Fix ownership/permissions on <checkpoint.dir>/current so the 2NN user can create it","Remove any stray regular file named 'current' blocking directory creation","Restart the SecondaryNameNode after repair; the next checkpoint cycle will recreate current/"],"exampleFix":"# before: current/ cannot be created\n$ ls -l /data/2nn/checkpoint\ntotal 0\n-rw-r--r-- 1 root root 0 current   # regular file shadowing the dir\n# after\n$ sudo rm /data/2nn/checkpoint/current && sudo -u hdfs hdfs secondarynamenode","handlingStrategy":"validation","validationCode":"// before relying on checkpoint storage at runtime\nfor (Iterator<StorageDirectory> it = storage.dirIterator(); it.hasNext();) {\n  File cur = it.next().getCurrentDir();\n  if (!cur.exists()) {\n    File parent = cur.getParentFile();\n    if (!parent.canWrite()) {\n      throw new IOException(\"Cannot create \" + cur + \": parent not writable\");\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"// the Checkpointer loop already catches IOException per cycle and retries at the\n// next checkpoint interval — inspect cause, repair the volume, let it retry:\ntry {\n  secondaryNameNode.doCheckpoint();\n} catch (IOException e) { // includes \"Could not create directory <curDir>\"\n  LOG.warn(\"Checkpoint failed, will retry: {}\", e.getMessage());\n}","preventionTips":["Disk-space and read-only-mount alerts on every checkpoint volume","Regular test checkpoints (small checkpoint interval in staging) to surface storage rot early","Keep ownership of <checkpoint.dir>/current consistent with the 2NN user in config management"],"tags":["hdfs","secondary-namenode","checkpoint","mkdir-failed","disk-full","storage"],"backgroundTag":"mkdir-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}