spring-projects/spring-ai · error · RuntimeException
Release collection failed!
Error message
Release collection failed!
What it means
dropCollection first releases (unloads) the collection and throws a plain RuntimeException("Release collection failed!") if the releaseCollection RPC reports an exception. Milvus requires releasing a loaded collection before dropping its index/collection in some flows.
Source
Thrown at vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java:600
catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn(
"Failed to obtain the embedding dimensions from the embedding model and fall backs to default: "
+ this.embeddingDimension,
e);
}
}
return OPENAI_EMBEDDING_DIMENSION_SIZE;
}
// used by the test as well
void dropCollection() {
R<RpcStatus> status = this.milvusClient
.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(this.collectionName).build());
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());
}
}View on GitHub (pinned to 98a7beda4f)
Solutions
- Inspect the cause exception for the Milvus status code.
- Check whether the collection is actually loaded before releasing (release of an unloaded collection can error on some versions).
- Verify server connectivity and retry.
- Confirm the client has permission to release collections.
- If the collection is stale/unreachable, drop it manually via the Milvus CLI/Attu and restart initialization.
Example fix
// before
// release fails because collection is not loaded
// after
if (milvusClient.hasCollection(HasCollectionParam.newBuilder().withCollectionName(name).build()).getData()) {
milvusClient.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(name).build());
} Defensive patterns
Strategy: try-catch
Validate before calling
// only release when the collection actually exists and is loaded
boolean exists = milvusClient.hasCollection(HasCollectionParam.newBuilder()
.withCollectionName(collectionName).build()).getData(Boolean.FALSE);
if (!exists) {
return; // nothing to release/drop
} Try / catch
try {
// triggered internally via schema checks / dropCollection
} catch (RuntimeException e) {
logger.error("Milvus release failed: {}", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
// check whether collection is loaded before retrying release
} Prevention
- Guard lifecycle calls with hasCollection checks.
- Avoid concurrent release/drop operations from multiple processes.
- Maintain stable connectivity — reconnect the MilvusServiceClient on failures.
When it happens
Trigger: Called from shouldFilterWithCustomMetadataFieldName (during schema-compatibility checks) or by users resetting schema when releaseCollection fails: collection not currently loaded, server connection failure, or permission issue.
Common situations: Collection already released by another process; Milvus connection dropped mid-operation; concurrent drop attempts.
Related errors
- Drop Collection failed!
- Collection loading failed!
- Failed to create collection
- Drop Index failed!
- Collection {collectionName} with the tenant: {tenantName} an
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/7e6ac8f16a1c6147.
Report an issue: GitHub.