{"record":{"id":"00fd08e5ea186aef","repo":"apache/seatunnel","slug":"failed-to-drop-collection-tablepath-getfullname","errorCode":null,"errorMessage":"Failed to drop collection: ${tablePath.getFullName()}","messagePattern":"Failed to drop collection: (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java","lineNumber":155,"sourceCode":"            db.createCollection(tablePath.getTableName());\n        } catch (Exception e) {\n            throw new CatalogException(\n                    \"Failed to create collection: \" + tablePath.getFullName(), e);\n        }\n    }\n\n    @Override\n    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        if (!tableExists(tablePath)) {\n            if (ignoreIfNotExists) return;\n            throw new TableNotExistException(name(), tablePath);\n        }\n        try {\n            MongoDatabase db = mongoClient.getDatabase(tablePath.getDatabaseName());\n            db.getCollection(tablePath.getTableName()).drop();\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to drop collection: \" + tablePath.getFullName(), e);\n        }\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        throw CommonError.unsupportedOperation(name(), \"create database \");\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        throw CommonError.unsupportedOperation(name(), \"drop database \");\n    }\n\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java#L137-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"Read-only service account used for catalog operations, network partition between check and drop, attempts to drop system.* collections, replica set without a primary.","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."],"exampleFix":"// before\ncatalog.dropTable(tablePath, false);\n// after\ntry {\n    catalog.dropTable(tablePath, false);\n} catch (CatalogException e) {\n    LOG.error(\"Drop failed: {}\", e.getCause(), e);\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"// preflight: user roles must include dropCollection\n// db.runCommand({connectionStatus: 1, showPrivileges: true})","typeGuard":null,"tryCatchPattern":"try {\n    catalog.dropTable(tablePath, false);\n} catch (CatalogException e) {\n    Throwable c = e.getCause();\n    if (c instanceof MongoTimeoutException) { /* retry; drop is idempotent */ }\n    else throw e;\n}","preventionTips":["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"],"tags":["mongodb","catalog","drop-collection"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}