{"record":{"id":"7e6ac8f16a1c6147","repo":"spring-projects/spring-ai","slug":"release-collection-failed","errorCode":null,"errorMessage":"Release collection failed!","messagePattern":"Release 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":600,"sourceCode":"\t\tcatch (Exception e) {\n\t\t\tif (logger.isWarnEnabled()) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\"Failed to obtain the embedding dimensions from the embedding model and fall backs to default: \"\n\t\t\t\t\t\t\t\t+ this.embeddingDimension,\n\t\t\t\t\t\te);\n\t\t\t}\n\t\t}\n\t\treturn OPENAI_EMBEDDING_DIMENSION_SIZE;\n\t}\n\n\t// used by the test as well\n\tvoid dropCollection() {\n\n\t\tR<RpcStatus> status = this.milvusClient\n\t\t\t.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(this.collectionName).build());\n\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}","sourceCodeStart":582,"sourceCodeEnd":618,"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#L582-L618","documentation":"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.","triggerScenarios":"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.","commonSituations":"Collection already released by another process; Milvus connection dropped mid-operation; concurrent drop attempts.","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."],"exampleFix":"// before\n// release fails because collection is not loaded\n// after\nif (milvusClient.hasCollection(HasCollectionParam.newBuilder().withCollectionName(name).build()).getData()) {\n    milvusClient.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(name).build());\n}","handlingStrategy":"try-catch","validationCode":"// only release when the collection actually exists and is loaded\nboolean exists = milvusClient.hasCollection(HasCollectionParam.newBuilder()\n        .withCollectionName(collectionName).build()).getData(Boolean.FALSE);\nif (!exists) {\n    return; // nothing to release/drop\n}","typeGuard":null,"tryCatchPattern":"try {\n    // triggered internally via schema checks / dropCollection\n} catch (RuntimeException e) {\n    logger.error(\"Milvus release failed: {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());\n    // check whether collection is loaded before retrying release\n}","preventionTips":["Guard lifecycle calls with hasCollection checks.","Avoid concurrent release/drop operations from multiple processes.","Maintain stable connectivity — reconnect the MilvusServiceClient on failures."],"tags":["milvus","collection","release","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"}