apache/hadoop · error · IOException
Cannot find target file - {}
Error message
Cannot find target file - {} What it means
concat() through the Router first resolves the target path with getFileRemoteLocation(trg), which returns the single remote location or, when ambiguous, probes candidates with getFileInfo. If it cannot find any location where the target exists (locations list empty or all getFileInfo probes null), it returns null and concat fails with IOException('Cannot find target file - <trg>'). Effectively: the target file does not exist in any subcluster behind the Router.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java:687
if (locs.size() != srcLocations.size()) {
throw new IOException("Rename of " + src + " to " + dst + " is not"
+ " allowed. The number of remote locations for both source and"
+ " target should be same.");
}
rpcClient.invokeConcurrent(locs, method);
} else {
rpcClient.invokeSequential(locs, method, null, null);
}
}
@Override
public void concat(String trg, String[] src) throws IOException {
rpcServer.checkOperation(NameNode.OperationCategory.WRITE);
// Concat only effects when all files in the same namespace.
RemoteLocation targetDestination = getFileRemoteLocation(trg);
if (targetDestination == null) {
throw new IOException("Cannot find target file - " + trg);
}
String targetNameService = targetDestination.getNameserviceId();
String[] sourceDestinations = new String[src.length];
for (int i = 0; i < src.length; i++) {
String sourceFile = src[i];
RemoteLocation srcLocation = getFileRemoteLocation(sourceFile);
if (srcLocation == null) {
throw new IOException("Cannot find source file - " + sourceFile);
}
sourceDestinations[i] = srcLocation.getDest();
if (!targetNameService.equals(srcLocation.getNameserviceId())) {
throw new IOException("Cannot concatenate source file " + sourceFile
+ " because it is located in a different namespace" + " with nameservice "
+ srcLocation.getNameserviceId() + " from the target file with nameservice "
+ targetNameService);
}View on GitHub (pinned to 2add963021)
Solutions
- Verify the target exists through the Router: hdfs dfs -ls <trg>; create it if missing
- Check the mount table maps <trg> to the nameservice where the file actually lives
- Run the concat directly against the owning nameservice if Router-side ambiguity persists
Defensive patterns
Strategy: validation
Validate before calling
// Verify target exists through the Router before concat
HdfsFileStatus st = clientProtocol.getFileInfo(trg);
if (st == null) {
throw new FileNotFoundException("concat target missing: " + trg);
} Try / catch
try {
clientProtocol.concat(trg, srcs);
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Cannot find target file")) {
// create/locate the target in the correct namespace, then retry
} else { throw e; }
} Prevention
- Existence-check the target before invoking concat
- Ensure the target's path resolves through a mount entry pointing at its real namespace
When it happens
Trigger: hdfs dfs -concat through the Router with a target path that does not exist; target exists only under a mount whose resolution returns multiple locations and none report the file (propagation delay or wrong mount); target path outside any mount (returns empty location list).
Common situations: Concat before the target file was created or after it was deleted; mount table changed so the old target path no longer maps to the owning nameservice; typo in the target path.
Related errors
- Cannot find source file - {}
- Cannot concatenate source file {} because it is located in a
- %s does not exist or is not file.
- Permission denied: {} is not allowed to change quota of {}
- Mount table state store is not available.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/bf859110bcec4fe0.
Report an issue: GitHub.