spring-projects/spring-ai · error · RuntimeException

Drop Collection failed!

Error message

Drop Collection failed!

What it means

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.

Source

Thrown at vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java:616

		if (status.getException() != null) {
			throw new RuntimeException("Release collection failed!", status.getException());
		}

		status = this.milvusClient
			.dropIndex(DropIndexParam.newBuilder().withCollectionName(this.collectionName).build());

		if (status.getException() != null) {
			throw new RuntimeException("Drop Index failed!", status.getException());
		}

		status = this.milvusClient.dropCollection(DropCollectionParam.newBuilder()
			.withDatabaseName(this.databaseName)
			.withCollectionName(this.collectionName)
			.build());

		if (status.getException() != null) {
			throw new RuntimeException("Drop Collection failed!", status.getException());
		}
	}

	@Override
	public org.springframework.ai.vectorstore.observation.VectorStoreObservationContext.Builder createObservationContextBuilder(
			String operationName) {

		return VectorStoreObservationContext.builder(VectorStoreProvider.MILVUS.value(), operationName)
			.collectionName(this.collectionName)
			.dimensions(this.embeddingModel.dimensions())
			.similarityMetric(getSimilarityMetric())
			.namespace(this.databaseName);
	}

	private String getSimilarityMetric() {
		if (!SIMILARITY_TYPE_MAPPING.containsKey(this.metricType)) {
			return this.metricType.name();
		}

View on GitHub (pinned to 98a7beda4f)

Solutions

  1. Read the cause exception for the Milvus status code.
  2. Ensure both releaseCollection and dropIndex succeeded before the drop.
  3. Verify databaseName and collectionName configuration values.
  4. Check the Milvus user has drop permissions on the collection.
  5. Drop the collection manually via Attu/Milvus CLI if needed.

Example fix

// before
.withDatabaseName(this.databaseName) // databaseName null/mismatched
// after
.withDatabaseName("default") // set the correct database name explicitly
Defensive patterns

Strategy: try-catch

Validate before calling

// verify release and dropIndex completed, and config names are correct, before drop
assert databaseName != null && collectionName != null : "databaseName/collectionName must be set";

Try / catch

try {
    // dropCollection invokes the drop RPC internally
} catch (RuntimeException e) {
    logger.error("Milvus drop collection failed: {}", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
    // fall back to manual drop via Attu/CLI if client state is stuck
}

Prevention

When it happens

Trigger: Called from shouldFilterWithCustomMetadataFieldName or schema reset when dropCollection RPC fails: collection still loaded or has dependents, connection failure, permission denied, or databaseName/collectionName mismatch.

Common situations: Release/drop-index steps succeeded but the server rejects the drop (collection in use by another process); wrong databaseName configured; permission-restricted environments.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/8808f84ff48002bf. Report an issue: GitHub.