{"record":{"id":"e7157dee85d3b64d","repo":"spring-projects/spring-ai","slug":"drop-index-failed","errorCode":null,"errorMessage":"Drop Index failed!","messagePattern":"Drop Index 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":607,"sourceCode":"\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}\n\n\t@Override\n\tpublic org.springframework.ai.vectorstore.observation.VectorStoreObservationContext.Builder createObservationContextBuilder(\n\t\t\tString operationName) {\n\n\t\treturn VectorStoreObservationContext.builder(VectorStoreProvider.MILVUS.value(), operationName)\n\t\t\t.collectionName(this.collectionName)","sourceCodeStart":589,"sourceCodeEnd":625,"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#L589-L625","documentation":"dropCollection then drops the index on the collection and throws a plain RuntimeException(\"Drop Index failed!\") if the dropIndex RPC returns an exception. The index removal on the Milvus server failed, blocking the subsequent dropCollection step.","triggerScenarios":"Called from shouldFilterWithCustomMetadataFieldName or dropCollection flow when milvusClient.dropIndex fails: index does not exist, collection still loaded, connection failure, or insufficient permissions.","commonSituations":"Index already dropped by a prior failed run; collection not released first (release step failed silently upstream); Milvus version requiring released state before index drop.","solutions":["Read the cause exception for the Milvus status code.","Ensure releaseCollection succeeded before dropIndex.","Handle/ignore 'index not found' cases and proceed to dropCollection.","Verify connectivity and permissions on the Milvus server.","Manually drop the index via Attu/CLI if the client state is stuck, then retry."],"exampleFix":"// before\n// dropIndex fails because collection was never released\n// after\nmilvusClient.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(name).build());\nmilvusClient.dropIndex(DropIndexParam.newBuilder().withCollectionName(name).build());","handlingStrategy":"try-catch","validationCode":"// ensure the collection was released before dropping the index\n// (releaseCollection must succeed first in the dropCollection flow)\nmilvusClient.releaseCollection(ReleaseCollectionParam.newBuilder().withCollectionName(collectionName).build());","typeGuard":null,"tryCatchPattern":"try {\n    // dropCollection flow invokes dropIndex internally\n} catch (RuntimeException e) {\n    String msg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();\n    if (msg != null && msg.contains(\"index not found\")) {\n        // tolerate already-dropped index and continue\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always release the collection before dropping its index.","Treat 'index not found' as idempotent success in reset flows.","Check permissions for index management operations."],"tags":["milvus","index","drop","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"}