Skip to content

[Bug]: Every request rebuilds its episodic memory: a session lookup, a partition open and an untimed Qdrant collection open each time #1773

Description

@wanghy73

Describe the bug

With the default configuration, each search and add re-opens its session (PostgreSQL), its segment-store partition (PostgreSQL) and its Qdrant collection, then closes them when the request ends, and the next request on the same session does it all again.

instance_cache_size defaults to 0 (packages/server/src/memmachine_server/episodic_memory/episodic_memory_manager.py:43), so release_ref closes an instance as soon as its last request ends (episodic_memory/instance_lru_cache.py), and every request misses the cache. Each miss runs get_session_info, open_or_create_partition and open_collection. open_collection (common/vector_store/qdrant_vector_store.py:855) records no metric, so its cost does not appear in any histogram; it shows only as time inside http_request_duration_seconds that no child step accounts for.

Steps to reproduce

  1. Default configuration (instance_cache_size unset), one server worker.
  2. Run a sustained search load on a few sessions (20 concurrent clients).
  3. Compare session_store_sqlalchemy_latency_seconds{operation="get_session_info"} and segment_store_sqlalchemy_latency_seconds{operation="open_or_create_partition"} counts with the /memories/search count: about one of each per request.
  4. Measured here: about 90 ms per search in those two calls, plus 33–63 ms per search that no recorded step accounts for. With four workers, about 5 ms plus 3 ms.

Expected behavior

A session in active use keeps its episodic memory between requests, or the documentation explains why caching is off by default. The Qdrant collection open is timed like the other store operations.

Environment

  • OS: Linux (Ubuntu 24.04), Docker
  • MemMachine Version: main at c99bc0e (0.3.9+50.gc99bc0e), image built from source; also seen at c08cf26
  • Development language version: Python 3.12 (in the image)
  • Backend: event memory, PostgreSQL 18, Qdrant 1.19.1

Additional context

Suggested fix: a non-zero default for instance_cache_size (or documentation of why 0 is the default and when to raise it), and an operation tracker around open_collection.

Activity

  1. added theissue type on Oct 6, 2026
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions