{"record":{"id":"e602d98b80934772","repo":"spring-projects/spring-ai","slug":"collection-loading-failed","errorCode":null,"errorMessage":"Collection loading failed!","messagePattern":"Collection loading 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":506,"sourceCode":"\n\t\tR<DescribeIndexResponse> indexDescriptionResponse = this.milvusClient\n\t\t\t.describeIndex(DescribeIndexParam.newBuilder()\n\t\t\t\t.withDatabaseName(this.databaseName)\n\t\t\t\t.withCollectionName(this.collectionName)\n\t\t\t\t.build());\n\n\t\tif (indexDescriptionResponse.getData() == null) {\n\t\t\tcreateIndex(this.databaseName, this.collectionName, this.embeddingFieldName, this.indexType,\n\t\t\t\t\tthis.metricType, this.indexParameters);\n\t\t}\n\n\t\tR<RpcStatus> loadCollectionStatus = this.milvusClient.loadCollection(LoadCollectionParam.newBuilder()\n\t\t\t.withDatabaseName(this.databaseName)\n\t\t\t.withCollectionName(this.collectionName)\n\t\t\t.build());\n\n\t\tif (loadCollectionStatus.getException() != null) {\n\t\t\tthrow new RuntimeException(\"Collection loading failed!\", loadCollectionStatus.getException());\n\t\t}\n\t}\n\n\tvoid createCollection(String databaseName, String collectionName, String idFieldName, boolean isAutoId,\n\t\t\tString contentFieldName, String metadataFieldName, String embeddingFieldName) {\n\t\tFieldType docIdFieldType = FieldType.newBuilder()\n\t\t\t.withName(idFieldName)\n\t\t\t.withDataType(DataType.VarChar)\n\t\t\t.withMaxLength(36)\n\t\t\t.withPrimaryKey(true)\n\t\t\t.withAutoID(isAutoId)\n\t\t\t.build();\n\t\tFieldType contentFieldType = FieldType.newBuilder()\n\t\t\t.withName(contentFieldName)\n\t\t\t.withDataType(DataType.VarChar)\n\t\t\t.withMaxLength(65535)\n\t\t\t.build();\n\t\tFieldType metadataFieldType = FieldType.newBuilder()","sourceCodeStart":488,"sourceCodeEnd":524,"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#L488-L524","documentation":"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.","triggerScenarios":"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).","commonSituations":"Milvus server low on memory so load is refused; collection creation failed silently before the load; databaseName/collectionName mismatch in configuration.","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."],"exampleFix":"// before\nMilvusVectorStore.builder(milvusClient).collectionName(\"my_coll\").build(); // fails if collection pre-exists in bad state\n// after\n// drop the stale collection first or use an init script:\n// milvusClient.dropCollection(DropCollectionParam.newBuilder().withCollectionName(\"my_coll\").build());\nMilusVectorStore.builder(milvusClient).collectionName(\"my_coll\").initializeSchema(true).build();","handlingStrategy":"try-catch","validationCode":"// check collection exists and server has capacity before initialization triggers load\nboolean exists = milvusClient.hasCollection(HasCollectionParam.newBuilder()\n        .withCollectionName(collectionName).build()).getData(Boolean.FALSE);\nif (!exists) {\n    throw new IllegalStateException(\"Collection missing; cannot load: \" + collectionName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    vectorStore.afterPropertiesSet(); // initialization includes loadCollection\n} catch (RuntimeException e) {\n    logger.error(\"Milvus collection load failed: {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());\n    // check server memory/quota before retrying\n}","preventionTips":["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."],"tags":["milvus","collection","load","initialization"],"backgroundTag":"database-query-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"}