apache/hadoop · error · FileAlreadyExistsException
File already exists.
Error message
File already exists.
What it means
Error "File already exists." thrown in apache/hadoop.
Source
Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java:1881
* @param isMetadataIncompleteState Flag indicating if metadata is incomplete.
* @throws IOException If an I/O error occurs during the rename operation.
* @throws FileAlreadyExistsException If the destination file already exists.
*/
private void handleRenameException(final String source,
final String destination, final String continuation,
final TracingContext tracingContext, final String sourceEtag,
final AbfsRestOperation op, boolean isMetadataIncompleteState,
AzureBlobFileSystemException e) throws IOException {
if (!op.hasResult()) {
throw e;
}
// ref: HADOOP-19393. Write permission checks can occur before validating
// rename operation's validity. If there is an existing destination path, it may be rejected
// with an authorization error. Catching and throwing FileAlreadyExistsException instead.
if (UNAUTHORIZED_BLOB_OVERWRITE.getErrorCode()
.equals(op.getResult().getStorageErrorCode())) {
throw new FileAlreadyExistsException(ERR_FILE_ALREADY_EXISTS);
}
// ref: HADOOP-18242. Rename failure occurring due to a rare case of
// tracking metadata being in incomplete state.
if (RENAME_DESTINATION_PARENT_PATH_NOT_FOUND.getErrorCode()
.equals(op.getResult().getStorageErrorCode())
&& !isMetadataIncompleteState) {
ABFS_METADATA_INCOMPLETE_RENAME_FAILURE.info(
"Rename Failure attempting to resolve tracking metadata state and retrying.");
isMetadataIncompleteState = true;
String sourceEtagAfterFailure = sourceEtag;
if (isEmpty(sourceEtagAfterFailure)) {
// Doing a HEAD call resolves the incomplete metadata state and
// then we can retry the rename operation.
AbfsRestOperation sourceStatusOp = getPathStatus(source, false,
tracingContext, null);
// Extract the sourceEtag, using the status Op, and set it
// for future rename recovery.View on GitHub (pinned to 2add963021)
Solutions
- Use overwrite=true in create() if replacing the file is intended.
- Choose a different target path or delete the existing file first.
When it happens
Trigger: create() without overwrite targets a path that already exists.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/fb94f538443e8de8.
Report an issue: GitHub.