{"record":{"id":"8808f84ff48002bf","repo":"spring-projects/spring-ai","slug":"drop-collection-failed","errorCode":null,"errorMessage":"Drop Collection failed!","messagePattern":"Drop Collection failed!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java","lineNumber":616,"sourceCode":"\n\t\tif (status.getException() != null) {\n\t\t\tthrow new RuntimeException(\"Release collection failed!\", status.getException());\n\t\t}\n\n\t\tstatus = this.milvusClient\n\t\t\t.dropIndex(DropIndexParam.newBuilder().withCollectionName(this.collectionName).build());\n\n\t\tif (status.getException() != null) {\n\t\t\tthrow new RuntimeException(\"Drop Index failed!\", status.getException());\n\t\t}\n\n\t\tstatus = this.milvusClient.dropCollection(DropCollectionParam.newBuilder()\n\t\t\t.withDatabaseName(this.databaseName)\n\t\t\t.withCollectionName(this.collectionName)\n\t\t\t.build());\n\n\t\tif (status.getException() != null) {\n\t\t\tthrow new RuntimeException(\"Drop Collection failed!\", status.getException());\n\t\t}\n\t}\n\n\t@Override\n\tpublic org.springframework.ai.vectorstore.observation.VectorStoreObservationContext.Builder createObservationContextBuilder(\n\t\t\tString operationName) {\n\n\t\treturn VectorStoreObservationContext.builder(VectorStoreProvider.MILVUS.value(), operationName)\n\t\t\t.collectionName(this.collectionName)\n\t\t\t.dimensions(this.embeddingModel.dimensions())\n\t\t\t.similarityMetric(getSimilarityMetric())\n\t\t\t.namespace(this.databaseName);\n\t}\n\n\tprivate String getSimilarityMetric() {\n\t\tif (!SIMILARITY_TYPE_MAPPING.containsKey(this.metricType)) {\n\t\t\treturn this.metricType.name();\n\t\t}","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java#L598-L634","documentation":"The final step of dropCollection calls milvusClient.dropCollection and throws a plain RuntimeException(\"Drop Collection failed!\") when the RPC response contains an exception. The collection itself could not be removed from the Milvus server after the release/drop-index steps.","triggerScenarios":"Called from shouldFilterWithCustomMetadataFieldName or schema reset when dropCollection RPC fails: collection still loaded or has dependents, connection failure, permission denied, or databaseName/collectionName mismatch.","commonSituations":"Release/drop-index steps succeeded but the server rejects the drop (collection in use by another process); wrong databaseName configured; permission-restricted environments.","solutions":["Read the cause exception for the Milvus status code.","Ensure both releaseCollection and dropIndex succeeded before the drop.","Verify databaseName and collectionName configuration values.","Check the Milvus user has drop permissions on the collection.","Drop the collection manually via Attu/Milvus CLI if needed."],"exampleFix":"// before\n.withDatabaseName(this.databaseName) // databaseName null/mismatched\n// after\n.withDatabaseName(\"default\") // set the correct database name explicitly","handlingStrategy":"try-catch","validationCode":"// verify release and dropIndex completed, and config names are correct, before drop\nassert databaseName != null && collectionName != null : \"databaseName/collectionName must be set\";","typeGuard":null,"tryCatchPattern":"try {\n    // dropCollection invokes the drop RPC internally\n} catch (RuntimeException e) {\n    logger.error(\"Milvus drop collection failed: {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());\n    // fall back to manual drop via Attu/CLI if client state is stuck\n}","preventionTips":["Confirm databaseName/collectionName configuration values are correct.","Grant the Milvus user drop privileges on the collection.","Ensure no other process holds the collection loaded during drops."],"tags":["milvus","collection","drop","lifecycle"],"backgroundTag":"database-write-failed","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}