{"record":{"id":"52e0fc08a4de8d45","repo":"apache/hadoop","slug":"cannot-truncate-file-with-striped-block","errorCode":null,"errorMessage":"Cannot truncate file with striped block {}","messagePattern":"Cannot truncate file with striped block (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirTruncateOp.java","lineNumber":93,"sourceCode":"    assert fsn.hasWriteLock(RwLockMode.GLOBAL);\n\n    FSDirectory fsd = fsn.getFSDirectory();\n    final String src;\n    final INodesInPath iip;\n    final boolean onBlockBoundary;\n    Block truncateBlock = null;\n    fsd.writeLock();\n    try {\n      iip = fsd.resolvePath(pc, srcArg, DirOp.WRITE);\n      src = iip.getPath();\n      if (fsd.isPermissionEnabled()) {\n        fsd.checkPathAccess(pc, iip, FsAction.WRITE);\n      }\n      INodeFile file = INodeFile.valueOf(iip.getLastINode(), src);\n\n      // not support truncating file with striped blocks\n      if (file.isStriped()) {\n        throw new UnsupportedOperationException(\n            \"Cannot truncate file with striped block \" + src);\n      }\n\n      final BlockStoragePolicy lpPolicy = fsd.getBlockManager()\n          .getStoragePolicy(\"LAZY_PERSIST\");\n\n      if (lpPolicy != null && lpPolicy.getId() == file.getStoragePolicyID()) {\n        throw new UnsupportedOperationException(\n            \"Cannot truncate lazy persist file \" + src);\n      }\n\n      // Check if the file is already being truncated with the same length\n      final BlockInfo last = file.getLastBlock();\n      if (last != null && last.getBlockUCState()\n          == BlockUCState.UNDER_RECOVERY) {\n        final BlockInfo truncatedBlock = last.getUnderConstructionFeature()\n            .getTruncateBlock();\n        if (truncatedBlock != null) {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirTruncateOp.java#L75-L111","documentation":"Error \"Cannot truncate file with striped block {}\" thrown in apache/hadoop.","triggerScenarios":"Truncating an erasure coded (striped) file whose last block is a striped block; truncate is only supported for EC files at block group boundaries.","commonSituations":"See trigger scenarios.","solutions":["Truncation of erasure-coded (striped) files is not supported; rewrite the file to the desired length instead.","Copy the needed prefix to a new file and delete the original."],"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"}