spring-projects/spring-ai · error · RuntimeException
Collection loading failed!
Error message
Collection loading failed!
What it means
createCollection loads the Milvus collection into memory after creating it and throws a plain RuntimeException("Collection loading failed!") if the loadCollection RPC returns an exception. Without loading, Milvus cannot serve searches on the collection.
Source
Thrown at vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStore.java:506
R<DescribeIndexResponse> indexDescriptionResponse = this.milvusClient
.describeIndex(DescribeIndexParam.newBuilder()
.withDatabaseName(this.databaseName)
.withCollectionName(this.collectionName)
.build());
if (indexDescriptionResponse.getData() == null) {
createIndex(this.databaseName, this.collectionName, this.embeddingFieldName, this.indexType,
this.metricType, this.indexParameters);
}
R<RpcStatus> loadCollectionStatus = this.milvusClient.loadCollection(LoadCollectionParam.newBuilder()
.withDatabaseName(this.databaseName)
.withCollectionName(this.collectionName)
.build());
if (loadCollectionStatus.getException() != null) {
throw new RuntimeException("Collection loading failed!", loadCollectionStatus.getException());
}
}
void createCollection(String databaseName, String collectionName, String idFieldName, boolean isAutoId,
String contentFieldName, String metadataFieldName, String embeddingFieldName) {
FieldType docIdFieldType = FieldType.newBuilder()
.withName(idFieldName)
.withDataType(DataType.VarChar)
.withMaxLength(36)
.withPrimaryKey(true)
.withAutoID(isAutoId)
.build();
FieldType contentFieldType = FieldType.newBuilder()
.withName(contentFieldName)
.withDataType(DataType.VarChar)
.withMaxLength(65535)
.build();
FieldType metadataFieldType = FieldType.newBuilder()View on GitHub (pinned to 98a7beda4f)
Solutions
- Inspect the cause exception for the Milvus status code.
- Verify the collection was actually created (hasCollection) before loading.
- Check Milvus server memory/quota — free resources or scale the cluster.
- Confirm databaseName and collectionName in the store configuration match the server.
- Retry initialization after the server recovers.
Example fix
// before
MilvusVectorStore.builder(milvusClient).collectionName("my_coll").build(); // fails if collection pre-exists in bad state
// after
// drop the stale collection first or use an init script:
// milvusClient.dropCollection(DropCollectionParam.newBuilder().withCollectionName("my_coll").build());
MilusVectorStore.builder(milvusClient).collectionName("my_coll").initializeSchema(true).build(); Defensive patterns
Strategy: try-catch
Validate before calling
// check collection exists and server has capacity before initialization triggers load
boolean exists = milvusClient.hasCollection(HasCollectionParam.newBuilder()
.withCollectionName(collectionName).build()).getData(Boolean.FALSE);
if (!exists) {
throw new IllegalStateException("Collection missing; cannot load: " + collectionName);
} Try / catch
try {
vectorStore.afterPropertiesSet(); // initialization includes loadCollection
} catch (RuntimeException e) {
logger.error("Milvus collection load failed: {}", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
// check server memory/quota before retrying
} Prevention
- Monitor Milvus server memory so load operations are not refused.
- Ensure collection creation succeeded before load (check hasCollection).
- Verify databaseName/collectionName configuration values match the server.
When it happens
Trigger: Invoked from afterPropertiesSet during VectorStore initialization, or from shouldFilterWithCustomMetadataFieldName, when milvusClient.loadCollection fails because the collection does not exist, was just created with an error, or the server rejects the load (insufficient memory/quota).
Common situations: Milvus server low on memory so load is refused; collection creation failed silently before the load; databaseName/collectionName mismatch in configuration.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Failed to create collection
- Collection {collectionName} with the tenant: {tenantName} an
- Failed to create Index
- Release collection failed!
- Drop Collection failed!
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/e602d98b80934772.
Report an issue: GitHub.