apache/seatunnel · error · CatalogException
Failed to drop collection
Error message
Failed to drop collection: ${tablePath.getFullName()} What it means
After the existence check passes, dropTable calls db.getCollection(name).drop(); any driver/server failure is wrapped in a CatalogException "Failed to drop collection: <fullName>". The wrapped cause holds the concrete MongoDB error.
Solutions
- Grant the user dropCollection (readWrite/admin) privilege on the database.
- Inspect e.getCause() for the Mongo error code and message.
- Retry the drop on transient network errors; drop is idempotent.
- Check replica set health; drop requires a writable primary.
- Do not attempt to drop system/internal collections via the catalog.
Example fix
// before
catalog.dropTable(tablePath, false);
// after
try {
catalog.dropTable(tablePath, false);
} catch (CatalogException e) {
LOG.error("Drop failed: {}", e.getCause(), e);
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: user roles must include dropCollection
// db.runCommand({connectionStatus: 1, showPrivileges: true}) Try / catch
try {
catalog.dropTable(tablePath, false);
} catch (CatalogException e) {
Throwable c = e.getCause();
if (c instanceof MongoTimeoutException) { /* retry; drop is idempotent */ }
else throw e;
} Prevention
- Grant dropCollection privilege to the catalog user
- Retry drops on transient network errors
- Avoid dropping system/internal collections
- Ensure replica set has a writable primary
When it happens
Trigger: User lacks dropCollection privilege, connection lost mid-drop, drop of a special/internal collection that forbids dropping (e.g., a collection backing a view or capped in restricted mode), or timeout on a large namespace.
Common situations: Read-only service account used for catalog operations, network partition between check and drop, attempts to drop system.* collections, replica set without a primary.
Related errors
- Database does not exist in catalog
- Database does not exist in catalog
- Failed to check database existence
- Failed to create collection
- Failed to list databases
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/00fd08e5ea186aef.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java:155
db.createCollection(tablePath.getTableName());
} catch (Exception e) {
throw new CatalogException(
"Failed to create collection: " + tablePath.getFullName(), e);
}
}
@Override
public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)
throws TableNotExistException, CatalogException {
if (!tableExists(tablePath)) {
if (ignoreIfNotExists) return;
throw new TableNotExistException(name(), tablePath);
}
try {
MongoDatabase db = mongoClient.getDatabase(tablePath.getDatabaseName());
db.getCollection(tablePath.getTableName()).drop();
} catch (Exception e) {
throw new CatalogException("Failed to drop collection: " + tablePath.getFullName(), e);
}
}
@Override
public void createDatabase(TablePath tablePath, boolean ignoreIfExists)
throws DatabaseAlreadyExistException, CatalogException {
throw CommonError.unsupportedOperation(name(), "create database ");
}
@Override
public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)
throws DatabaseNotExistException, CatalogException {
throw CommonError.unsupportedOperation(name(), "drop database ");
}
@Override
public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)
throws TableNotExistException, CatalogException {View on GitHub (pinned to cf67b549a7)