prestodb/presto · error · IOException
Metadata for view %s already exists
Error message
Metadata for view %s already exists
What it means
This is the wrapped IOException raised when createViewMetadata detects that a view's metadata znode already exists at viewPath (checkExists != null). The IOException 'Metadata for view %s already exists' is caught by the surrounding handler and rethrown as PrestoException ZOOKEEPER_ERROR ('ZK error when checking if view already exists') with the IOException as cause. It signals CREATE VIEW collision, not a ZK failure.
Source
Thrown at presto-accumulo/src/main/java/com/facebook/presto/accumulo/metadata/ZooKeeperMetadataManager.java:225
}
public void deleteTableMetadata(SchemaTableName tableName)
{
try {
curator.delete().deletingChildrenIfNeeded().forPath(getTablePath(tableName));
}
catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when deleting table metadata", e);
}
}
public void createViewMetadata(AccumuloView view)
{
SchemaTableName tableName = view.getSchemaTableName();
String viewPath = getTablePath(tableName);
try {
if (curator.checkExists().forPath(viewPath) != null) {
throw new IOException(format("Metadata for view %s already exists", tableName));
}
}
catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when checking if view already exists", e);
}
try {
curator.create().creatingParentsIfNeeded().forPath(viewPath, toJsonBytes(view));
}
catch (Exception e) {
throw new PrestoException(ZOOKEEPER_ERROR, "Error creating view znode in ZooKeeper", e);
}
}
public void deleteViewMetadata(SchemaTableName tableName)
{
try {
curator.delete().deletingChildrenIfNeeded().forPath(getTablePath(tableName));View on GitHub (pinned to 55bb57d202)
Solutions
- Drop the existing view (or its znode) before recreating, or use CREATE OR REPLACE VIEW if supported.
- Inspect ZooKeeper at the connector metadata root and delete stale view znodes from failed operations.
- Check for concurrent creators (multiple coordinators) and serialize DDL.
- Verify table vs view naming collision — the connector uses one path per schema.table.
- Review the PrestoException's cause: if it contains this IOException, no ZK repair is needed — it's a naming conflict.
Example fix
// before CREATE VIEW myview AS SELECT ...; // after DROP VIEW IF EXISTS myview; CREATE VIEW myview AS SELECT ...;
Defensive patterns
Strategy: validation
Validate before calling
// Before CREATE VIEW, check for an existing view
boolean exists = metadata.getView(new SchemaTableName(schema, table)) != null;
if (exists) { drop or replace first } Type guard
null
Try / catch
try {
metadata.createViewMetadata(view);
} catch (PrestoException e) {
if (e.getCause() instanceof IOException && e.getCause().getMessage().contains("already exists")) {
throw new PrestoException(ALREADY_EXISTS, "View already exists: " + viewName, e);
}
throw e;
} Prevention
- Use CREATE OR REPLACE VIEW or DROP VIEW IF EXISTS before re-creating
- Clean up stale znodes after failed DDL operations
- Avoid concurrent CREATE VIEW for the same schema.table name
- Check the PrestoException cause — 'already exists' is a naming conflict, not a ZK outage
- Document view-name collisions between views and tables in the connector
When it happens
Trigger: Calling createViewMetadata(view) for a SchemaTableName whose znode already exists in ZooKeeper — i.e. a view (or leftover metadata) with the same schema.table was already created. The checkExists succeeds and returns non-null, triggering the IOException.
Common situations: CREATE VIEW on an existing view name without OR REPLACE; leftover znodes from a failed prior create or incomplete cleanup; two coordinators concurrently creating the same view; case-insensitive schema collision.
Related errors
- UNEXPECTED_ACCUMULO_ERROR
- UNEXPECTED_ACCUMULO_ERROR
- NOT_SUPPORTED
- UNEXPECTED_ACCUMULO_ERROR
- ACCUMULO_TABLE_DNE
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/1f9cc1fc40173848.
Report an issue: GitHub.