Skip to content

[Bug]: HTTP clients leave an unreleasable entry in SharedSystemClient._identifier_to_system after close() (orphan from _populate_data_from_system) #7915

Open

Description

@JIAQIA

What happened?

For HTTP-backed clients the system identifier is a fresh uuid4() on every call to SharedSystemClient._get_identifier_from_settings. Client.__init__ creates the internal admin client with AdminClient.from_system(self._system), which calls _populate_data_from_system(system). That method computes the identifier again (a new uuid) and stores the same System under it, without touching _identifier_to_refcount.

Client.close() only releases self._identifier and self._admin_client._identifier, so the extra entry stays in the class-level _identifier_to_system forever, holding a reference to the stopped System. Every HttpClient created and closed in a long-running process leaves one entry behind.

PersistentClient is not affected, because its identifier is the persist path, so the extra registration overwrites the same key.

AsyncClient.create has the same pattern twice (_populate_data_from_system(self._system) plus AsyncAdminClient.from_system(...)), so it leaves two such entries. This is in addition to #7694, where AsyncClient has no close() at all.

Minimal repro (chromadb 1.5.9, Python 3.11)

import chromadb
from chromadb.config import Settings
from chromadb.api.shared_system_client import SharedSystemClient as S

# a chroma server running on 127.0.0.1:8000
before = set(S._identifier_to_system)
c = chromadb.HttpClient(host="127.0.0.1", port=8000, settings=Settings(anonymized_telemetry=False))
print(len(set(S._identifier_to_system) - before))  # 3
c.close()
print(len(set(S._identifier_to_system) - before))  # 1  <- expected 0

For comparison, PersistentClient(path=...) prints 1 and then 0.

Expected

After close(), no entry created by the client stays in _identifier_to_system. For example, _populate_data_from_system could reuse the system's existing identifier instead of generating a new one, or the admin client could be built from the existing identifier.

Versions

chromadb 1.5.9 (latest on PyPI), Python 3.11, macOS.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions