apache/iceberg · error · AlreadyExistsException
Cannot commit because its Glue table already exists when…
Error message
Cannot commit %s because its Glue table already exists when trying to create one
What it means
AlreadyExistsException thrown by GlueTableOperations.handleAWSExceptions when the Glue CreateTable call fails with Glue's AlreadyExistsException. The commit path attempted to register the Iceberg table as a new Glue table, but a table with that database/name already exists in the Glue Data Catalog. This is a registration conflict, not a transient retryable commit failure.
Solutions
- Drop or rename the existing Glue table if it is a leftover, then retry the create — verify it is not a live table first.
- Load the existing table instead of creating: use catalog.loadTable(identifier) and confirm it is a valid Iceberg table (check for metadata_location parameter).
- If the existing Glue entry is corrupt, delete it with aws glue delete-table (or DROP TABLE) and re-register via catalog.registerTable or createTable.
- Serialize table-creation logic in your orchestration so only one process creates a given table.
Example fix
// before
Table table = catalog.createTable(identifier, schema); // fails if Glue entry already exists
// after
Table table;
try {
table = catalog.createTable(identifier, schema);
} catch (AlreadyExistsException e) {
table = catalog.loadTable(identifier); // reuse the existing table
} Defensive patterns
Strategy: try-catch
Validate before calling
if (catalog.tableExists(identifier)) {
// load instead of create
} Try / catch
try {
table = catalog.createTable(identifier, schema);
} catch (org.apache.iceberg.exceptions.AlreadyExistsException e) {
table = catalog.loadTable(identifier);
} Prevention
- Check tableExists before createTable in idempotent job code
- Clean up leftover Glue entries from failed runs before re-creating
- Serialize table creation through a single orchestrator step
- Verify the existing Glue entry is a valid Iceberg table before reusing it
When it happens
Trigger: doCommit on a table whose Glue backing entry was expected to be absent (createTable/new-table registration) while a Glue table with the same name already exists; two processes racing to create the same table in the Glue catalog.
Common situations: Re-running a CREATE TABLE after a partially failed earlier attempt left the Glue entry behind; the Glue table exists but is not a valid Iceberg table; a race between two jobs creating the same table name; leftover table from a dropped/misconfigured database.
Related errors
- Cannot commit because base metadata location ' ' is not…
- Cannot commit because Glue cannot access the requested…
- Cannot commit because Glue cannot find the requested entity
- Cannot commit because Glue detected concurrent update
- Cannot commit because Glue encountered a validation…
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/76347c6b3a412c32.
Report an issue: GitHub.
Appendix: source
Thrown at aws/src/main/java/org/apache/iceberg/aws/glue/GlueTableOperations.java:359
TableInput.builder()
.applyMutation(
builder ->
IcebergToGlueConverter.setTableInputInformation(builder, metadata))
.name(tableName)
.tableType(GLUE_EXTERNAL_TABLE_TYPE)
.parameters(parameters)
.build())
.build());
}
}
private void handleAWSExceptions(AwsServiceException persistFailure) {
if (persistFailure instanceof ConcurrentModificationException) {
throw new CommitFailedException(
persistFailure, "Cannot commit %s because Glue detected concurrent update", tableName());
} else if (persistFailure
instanceof software.amazon.awssdk.services.glue.model.AlreadyExistsException) {
throw new AlreadyExistsException(
persistFailure,
"Cannot commit %s because its Glue table already exists when trying to create one",
tableName());
} else if (persistFailure instanceof EntityNotFoundException) {
throw new NotFoundException(
persistFailure,
"Cannot commit %s because Glue cannot find the requested entity",
tableName());
} else if (persistFailure instanceof AccessDeniedException) {
throw new ForbiddenException(
persistFailure,
"Cannot commit %s because Glue cannot access the requested resources",
tableName());
} else if (persistFailure
instanceof software.amazon.awssdk.services.glue.model.ValidationException) {
throw new ValidationException(
persistFailure,
"Cannot commit %s because Glue encountered a validation exception "View on GitHub (pinned to 86d9c8fc54)