Skip to content

[BUG] Default ORT EF leaked in embedded CreateCollection for existing collections #494

@tazarov

Description

@tazarov

Description

When CreateCollection is called with CreateIfNotExists=true (i.e. via GetOrCreateCollection) and the collection already exists (isNewCreation=false), PrepareAndValidateCollectionRequest() unconditionally creates a default ORT EmbeddingFunction that holds native ONNX Runtime resources (session handles, environment state).

The isNewCreation=false path then sets overrideEF = nil and overrideContentEF = nil, discarding the reference to the default ORT EF without ever closing it. The EF is never stored in collection state or passed to a collection constructor, so its Close() is never called.

Impact

Every call to GetOrCreateCollection on the embedded client for an already-existing collection leaks one ORT EmbeddingFunction's native ONNX resources. Over many calls this accumulates leaked session handles and environment state.

Affected code

  • pkg/api/v2/client_local_embedded.go: CreateCollection lines 347, 408-411
  • pkg/api/v2/client.go: PrepareAndValidateCollectionRequest lines 274-284 (where default ORT EF is created)

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions