{"record":{"id":"0bf20a422fd8ffe5","repo":"apache/hadoop","slug":"rename-of-to-is-not-allowed-the-number-of-r-0bf20a","errorCode":null,"errorMessage":"Rename of {} to {} 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":263,"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      asyncComplete(\n          rbfRename.routerFedRename(src, dst, srcLocations, dstLocations));\n      return asyncReturn(Boolean.class);\n    }\n    RemoteMethod method = new RemoteMethod(\"rename\",\n        new Class<?>[] {String.class, String.class},\n        new RemoteParam(), dstParam);\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.invokeAll(locs, method);\n      } else {\n        rpcClient.invokeSequential(locs, method, Boolean.class,\n            Boolean.TRUE);\n      }\n    });\n    return asyncReturn(Boolean.class);\n  }\n\n  @Override\n  public void rename2(\n      final String src, final String dst,\n      final Options.Rename... options) throws IOException {\n    rpcServer.checkOperation(NameNode.OperationCategory.WRITE);\n","sourceCodeStart":245,"sourceCodeEnd":281,"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#L245-L281","documentation":"In RouterAsyncClientProtocol.rename (async mode), when the destination is a multi-destination directory (isMultiDestDirectory true, i.e. the mount is 'ALL' ordered and the dir exists in the subclusters), the Router fans the rename out to every destination. It first asserts locs.size() == srcLocations.size(); if the destination mount and source mount have different numbers of remote locations, the fan-out cannot be paired one-to-one and IOException is thrown with both paths. This protects against partial renames across mismatched multi-destination mounts.","triggerScenarios":"rename(src, dst) through an async-mode Router where dst's parent is a multi-destination mount (e.g. 3 destinations) and src's mount has a different destination count (e.g. 1), or vice versa.","commonSituations":"Mount table evolution: one multi-dest mount extended with another nameservice while the related mount was not; ops teams adding standby namespaces to only one side of a mirrored pair.","solutions":["Align the mount table entries so source and destination mounts list the same number (and order) of destinations: hdfs dfsrouteradmin -add /src ns1,ns2 and /dst ns1,ns2, then refresh","Rename to a destination under a single-destination mount, or do a two-step rename through such a path","Audit with hdfs dfsrouteradmin -ls to see the destination lists of both mounts before retrying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before rename across multi-dest mounts, compare destination counts:\n// hdfs dfsrouteradmin -ls /srcMount  and  /dstMount\n// must show the same number of destinations in the same order.","typeGuard":null,"tryCatchPattern":"catch (IOException e) {\n  if (e.getMessage().contains(\"number of remote locations\")) {\n    // align mount entries or route the rename through a single-dest path\n  }\n}","preventionTips":["Keep mirrored multi-destination mounts symmetrical: same namespaces, same order on both sides","Automate mount-table validation (destination count parity) after every dfsrouteradmin edit","Prefer renames within one mount entry over renames across mount boundaries"],"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"}