prestodb/presto · error · PrestoException
ALREADY_EXISTS
ALREADY_EXISTS
Error message
Partition already exists for table '%s.%s': %s
What it means
While adding a partition inside a semi-transactional session, an existing pending action for the same partition conflicts: e.g. a DROP followed by an ADD issued by a different user, or otherwise incompatible sequential actions, so a TRANSACTION_CONFLICT PrestoException is thrown to prevent two users mutating the same partition in one transaction.
Source
Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:894
partitionActionsOfTable.put(
partition.getValues(),
new Action<>(ActionType.ADD, new PartitionAndMore(partition, currentLocation, Optional.empty(), statistics, statistics), context));
return;
}
switch (oldPartitionAction.getType()) {
case DROP: {
if (!oldPartitionAction.getContext().getIdentity().getUser().equals(session.getUser())) {
throw new PrestoException(TRANSACTION_CONFLICT, "Operation on the same partition with different user in the same transaction is not supported");
}
partitionActionsOfTable.put(
partition.getValues(),
new Action<>(ActionType.ALTER, new PartitionAndMore(partition, currentLocation, Optional.empty(), statistics, statistics), context));
break;
}
case ADD:
case ALTER:
case INSERT_EXISTING:
throw new PrestoException(ALREADY_EXISTS, format("Partition already exists for table '%s.%s': %s", databaseName, tableName, partition.getValues()));
default:
throw new IllegalStateException("Unknown action type");
}
}
public synchronized void dropPartition(
ConnectorSession session,
String databaseName,
String tableName,
String tablePath,
List<String> partitionValues)
{
setShared();
Map<List<String>, Action<PartitionAndMore>> partitionActionsOfTable = partitionActions.computeIfAbsent(new SchemaTableName(databaseName, tableName), k -> new HashMap<>());
Action<PartitionAndMore> oldPartitionAction = partitionActionsOfTable.get(partitionValues);
if (oldPartitionAction == null) {
HdfsContext context = new HdfsContext(session, databaseName, tableName, tablePath, false);
partitionActionsOfTable.put(partitionValues, new Action<>(ActionType.DROP, null, context));View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure a single transaction does not interleave partition drop/add across different users
- Split conflicting operations into separate transactions
- Coordinate concurrent jobs so they do not target the same partition simultaneously
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:894 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/3e7487bb767fe33e.
Report an issue: GitHub.