{"record":{"id":"03c7093c1d384ab0","repo":"apache/hadoop","slug":"rename-of-src-to-dst-is-not-allowed-the-numbe","errorCode":null,"errorMessage":"Rename of {src} to {dst} is not allowed. The number of remote locations for both source and target should be same.","messagePattern":"Rename of (.+?) to (.+?) is not allowed\\. The number of remote locations for both source and target should be same\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncClientProtocol.java","lineNumber":301,"sourceCode":"        rpcServer.getLocationsForPath(src, true, false);\n    final List<RemoteLocation> dstLocations =\n        rpcServer.getLocationsForPath(dst, false, false);\n    // srcLocations may be trimmed by getRenameDestinations()\n    final List<RemoteLocation> locs = new LinkedList<>(srcLocations);\n    RemoteParam dstParam = getRenameDestinations(locs, dstLocations);\n    if (locs.isEmpty()) {\n      rbfRename.routerFedRename(src, dst, srcLocations, dstLocations);\n      asyncComplete(null);\n      return;\n    }\n    RemoteMethod method = new RemoteMethod(\"rename2\",\n        new Class<?>[] {String.class, String.class, options.getClass()},\n        new RemoteParam(), dstParam, options);\n    isMultiDestDirectory(src);\n    asyncApply((AsyncApplyFunction<Boolean, Boolean>) isMultiDestDirectory -> {\n      if (isMultiDestDirectory) {\n        if (locs.size() != srcLocations.size()) {\n          throw new IOException(\"Rename of \" + src + \" to \" + dst + \" is not\"\n              + \" allowed. The number of remote locations for both source and\"\n              + \" target should be same.\");\n        }\n        rpcClient.invokeConcurrent(locs, method);\n      } else {\n        rpcClient.invokeSequential(locs, method, null, null);\n      }\n    });\n  }\n\n  @Override\n  public void concat(String trg, String[] src) throws IOException {\n    rpcServer.checkOperation(NameNode.OperationCategory.WRITE);\n\n    // Concat only effects when all files in the same namespace.\n    getFileRemoteLocation(trg);\n    asyncApply((AsyncApplyFunction<RemoteLocation, Object>) targetDestination -> {\n      if (targetDestination == null) {","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncClientProtocol.java#L283-L319","documentation":"Identical guard to the rename variant, but on RouterAsyncClientProtocol.rename2 (rename with Rename options, used by modern clients). Before fanning rename2 out concurrently to all locations of a multi-destination directory, the Router requires srcLocations.size() == locs.size(); a mismatch aborts with IOException naming src and dst. Without the check, concurrent invocation would leave the replicas of the multi-dest tree inconsistently renamed.","triggerScenarios":"rename2(src, dst, options) via an async Router where the source and destination mounts have different numbers of remote locations and dst is a multi-destination directory.","commonSituations":"Same as rename: asymmetric multi-destination mounts after mount-table edits; tools that use FileSystem.rename (which maps to rename2) against federated multi-dest trees.","solutions":["Make the source and destination mount entries list identical destination sets (same namespaces, same order) with hdfs dfsrouteradmin -add and refresh","Route the rename through a single-destination subtree (two-step rename)","Verify both mount entries with hdfs dfsrouteradmin -ls before issuing batch renames"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IOException e) {\n  if (e.getMessage().contains(\"number of remote locations\")) {\n    // rename2 blocked by asymmetric multi-dest mounts: align entries,\n    // or two-step rename via a single-destination subtree\n  }\n}","preventionTips":["Apply mount table changes that add destinations to all related mounts in one maintenance step","Validate multi-dest parity in CI against a router test fixture when tooling relies on FileSystem.rename","Alert on rename failures mentioning 'remote locations' to catch mount drift early"],"tags":["hadoop","hdfs","rbf","rename","multi-destination","mount-table","async-rpc"],"backgroundTag":"rename-destinations-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}