{"record":{"id":"52fa18be915a1030","repo":"apache/hadoop","slug":"the-ownership-on-the-staging-directory-stagingar","errorCode":null,"errorMessage":"The ownership on the staging directory ${stagingArea} is not as expected. It is owned by ${fileOwner}. The directory must be owned by the submitter ${currentUser.getShortUserName()} or ${currentUser.getUserName()} or ${realUser.getShortUserName()} or ${realUser.getUserName()}","messagePattern":"The ownership on the staging directory (.+?) is not as expected\\. It is owned by (.+?)\\. The directory must be owned by the submitter (.+?) or (.+?) or (.+?) or (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java","lineNumber":148,"sourceCode":"  public static Path getStagingDir(Cluster cluster, Configuration conf,\n      UserGroupInformation realUser) throws IOException, InterruptedException {\n    Path stagingArea = cluster.getStagingAreaDir();\n    FileSystem fs = stagingArea.getFileSystem(conf);\n    UserGroupInformation currentUser = realUser.getCurrentUser();\n    try {\n      FileStatus fsStatus = fs.getFileStatus(stagingArea);\n      String fileOwner = fsStatus.getOwner();\n      if (!(fileOwner.equals(currentUser.getShortUserName()) || fileOwner\n          .equalsIgnoreCase(currentUser.getUserName()) || fileOwner\n          .equals(realUser.getShortUserName()) || fileOwner\n          .equalsIgnoreCase(realUser.getUserName()))) {\n        String errorMessage = \"The ownership on the staging directory \" +\n            stagingArea + \" is not as expected. \" +\n            \"It is owned by \" + fileOwner + \". The directory must \" +\n            \"be owned by the submitter \" + currentUser.getShortUserName()\n            + \" or \" + currentUser.getUserName();\n        if (!realUser.getUserName().equals(currentUser.getUserName())) {\n          throw new IOException(\n              errorMessage + \" or \" + realUser.getShortUserName() + \" or \"\n                  + realUser.getUserName());\n        } else {\n          throw new IOException(errorMessage);\n        }\n      }\n      if (!fsStatus.getPermission().equals(JOB_DIR_PERMISSION)) {\n        LOG.info(\"Permissions on staging directory \" + stagingArea + \" are \" +\n            \"incorrect: \" + fsStatus.getPermission() + \". Fixing permissions \" +\n            \"to correct value \" + JOB_DIR_PERMISSION);\n        fs.setPermission(stagingArea, JOB_DIR_PERMISSION);\n      }\n    } catch (FileNotFoundException e) {\n      FileSystem.mkdirs(fs, stagingArea, new FsPermission(JOB_DIR_PERMISSION));\n    }\n    return stagingArea;\n  }\n}","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java#L130-L166","documentation":"Error \"The ownership on the staging directory ${stagingArea} is not as expected. It is owned by ${fileOwner}. The directory must be owned by the submitter ${currentUser.getShortUserName()} or ${currentUser.getUserName()} or ${realUser.getShortUserName()} or ${realUser.getUserName()}\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobSubmissionFiles.java:148 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix ownership of the staging directory so it is owned by the submitting user (or real user in proxy setups), e.g. chown the directory or resubmit as the correct user."],"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"}