prestodb/presto · error · PrestoException
HIVE_PATH_ALREADY_EXISTS
HIVE_PATH_ALREADY_EXISTS
Error message
Unable to create directory %s: target directory already exists
What it means
During commit of a semi-transactional session, a staging/target directory rename or create finds the target path already exists when it must be fresh; the HDFS directory creation helper refuses to overwrite and reports the target path, preventing duplicate or clobbered data directories.
Source
Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:1412
context,
hdfsEnvironment,
currentPath.get(),
targetPath,
() -> cleanUpTasksForAbort.add(new DirectoryCleanUpTask(context, targetPath, true)));
}
else {
// CREATE TABLE AS SELECT partitioned table, or
// CREATE TABLE AS SELECT unpartitioned table without temporary staging directory
// CREATE TABLE partitioned/unpartitioned table (without data)
if (pathExists(context, hdfsEnvironment, targetPath)) {
if (currentPath.isPresent() && currentPath.get().equals(targetPath)) {
// It is okay to skip directory creation when currentPath is equal to targetPath
// because the directory may have been created when creating partition directories.
// However, it is important to note that the two being equal does not guarantee
// a directory had been created.
}
else {
throw new PrestoException(
HIVE_PATH_ALREADY_EXISTS,
format("Unable to create directory %s: target directory already exists", targetPath));
}
}
else {
cleanUpTasksForAbort.add(new DirectoryCleanUpTask(context, targetPath, true));
createDirectory(context, hdfsEnvironment, targetPath);
}
}
}
addTableOperations.add(new CreateTableOperation(metastoreContext, table, tableAndMore.getPrincipalPrivileges(), tableAndMore.isIgnoreExisting(), tableAndMore.getConstraints()));
if (!isPrestoView(table)) {
updateStatisticsOperations.add(new UpdateStatisticsOperation(metastoreContext,
table.getSchemaTableName(),
Optional.empty(),
tableAndMore.getStatisticsUpdate(),
false));
}View on GitHub (pinned to 55bb57d202)
Solutions
- Remove stale staging/target directories left over from a previous failed query, then retry
- Ensure concurrent queries do not commit the same table/partition target paths simultaneously
- Check for orphaned directories from aborted transactions and clean them via cleanup tooling
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:1412 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/3580a63651c96a6e.
Report an issue: GitHub.