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

  1. Inspect the cause exception for the Milvus status code.
  2. Check whether the collection is actually loaded before releasing (release of an unloaded collection can error on some versions).
  3. Verify server connectivity and retry.
  4. Confirm the client has permission to release collections.
  5. 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

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


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/7e6ac8f16a1c6147. Report an issue: GitHub.