{"record":{"id":"6d1d4bc36e6582d4","repo":"apache/hadoop","slug":"the-lazy-persist-storage-policy-has-been-disabled","errorCode":null,"errorMessage":"The LAZY_PERSIST storage policy has been disabled by the administrator.","messagePattern":"The LAZY_PERSIST storage policy has been disabled by the administrator\\.","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirWriteFileOp.java","lineNumber":825,"sourceCode":"    BlockUnderConstructionFeature uc = b.getUnderConstructionFeature();\n    if (uc != null) {\n      uc.appendUCPartsConcise(sb);\n    }\n    sb.append(\" for \").append(src);\n    NameNode.stateChangeLog.info(sb.toString());\n  }\n\n  private static void setNewINodeStoragePolicy(BlockManager bm,\n      INodesInPath iip, boolean isLazyPersist) throws IOException {\n    INodeFile inode = iip.getLastINode().asFile();\n    if (isLazyPersist) {\n      BlockStoragePolicy lpPolicy =\n          bm.getStoragePolicy(\"LAZY_PERSIST\");\n\n      // Set LAZY_PERSIST storage policy if the flag was passed to\n      // CreateFile.\n      if (lpPolicy == null) {\n        throw new HadoopIllegalArgumentException(\n            \"The LAZY_PERSIST storage policy has been disabled \" +\n            \"by the administrator.\");\n      }\n      inode.setStoragePolicyID(lpPolicy.getId(),\n                                 iip.getLatestSnapshotId());\n    } else {\n      BlockStoragePolicy effectivePolicy =\n          bm.getStoragePolicy(inode.getStoragePolicyID());\n\n      if (effectivePolicy != null &&\n          effectivePolicy.isCopyOnCreateFile()) {\n        // Copy effective policy from ancestor directory to current file.\n        inode.setStoragePolicyID(effectivePolicy.getId(),\n                                 iip.getLatestSnapshotId());\n      }\n    }\n  }\n","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirWriteFileOp.java#L807-L843","documentation":"When a file is created with CreateFlag.LAZY_PERSIST, setNewINodeStoragePolicy looks up the LAZY_PERSIST BlockStoragePolicy to stamp on the new inode. If storage policies are administratively disabled (dfs.storage.policy.enabled=false on the NameNode), getStoragePolicy returns null and creation fails with HadoopIllegalArgumentException before the file exists.","triggerScenarios":"fs.create(path, EnumSet.of(CreateFlag.CREATE, CreateFlag.LAZY_PERSIST), ...) against a NameNode with dfs.storage.policy.enabled=false.","commonSituations":"Clusters where admins disabled the storage-policy feature; frameworks or examples that unconditionally pass LAZY_PERSIST; porting applications between clusters with different policy settings.","solutions":["Drop the LAZY_PERSIST flag and create with plain CREATE","Ask admins to enable dfs.storage.policy.enabled=true in hdfs-site.xml (NameNode restart; cluster-wide behavior change)","If lazy persist is required, also ensure datanodes expose RAM_DISK volumes in dfs.datanode.data.dir"],"exampleFix":"// before\nFSDataOutputStream out = fs.create(path,\n    EnumSet.of(CreateFlag.CREATE, CreateFlag.LAZY_PERSIST), 4096);\n\n// after\nFSDataOutputStream out = fs.create(path,\n    EnumSet.of(CreateFlag.CREATE), 4096);","handlingStrategy":"validation","validationCode":"boolean policiesEnabled = conf.getBoolean(\"dfs.storage.policy.enabled\", true);\nEnumSet<CreateFlag> flags = policiesEnabled\n    ? EnumSet.of(CreateFlag.CREATE, CreateFlag.LAZY_PERSIST)\n    : EnumSet.of(CreateFlag.CREATE);","typeGuard":null,"tryCatchPattern":"try {\n  out = fs.create(path, EnumSet.of(CreateFlag.CREATE, CreateFlag.LAZY_PERSIST), 4096);\n} catch (HadoopIllegalArgumentException e) {\n  // LAZY_PERSIST disabled cluster-wide: fall back to a normal create\n  out = fs.create(path, EnumSet.of(CreateFlag.CREATE), 4096);\n}","preventionTips":["Make the LAZY_PERSIST flag conditional on cluster config","Check dfs.storage.policy.enabled when porting apps between clusters","Prefer setting the policy after create for a clear, recoverable failure"],"tags":["hdfs","storage-policy","lazy-persist","create-flag","namenode-config"],"backgroundTag":"feature-disabled-by-config","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}