Skip to content

The expiry sweep never retries a search mirror that failed #399

Closed

Description

@zlareb1

Component

Server: memory expiry sweep (server/memory/app/expiry.py).

Describe what's wrong

When the expiry sweep's search mirror fails, nothing retries it. run_pass writes the memory version rows first, then _mirror_embeddings_batch; a mirror failure is logged and returned as a mirror: entry in failures. The comment there says "The next pass that sees the key re-mirrors it", but the next pass never sees the key: find_expired_candidates (server/memory/store/sweeps.py) selects only rows with tombstoned_at IS NULL and a past expires_at, and the version row the pass wrote is tombstoned (tombstone) or has its expiry cleared (demote).

What is left behind depends on the action:

  • demote: the memory is live again, but its memory_embeddings rows keep the past expires_at, so search keeps hiding it;
  • anonymize: the key's memory_embeddings and entity_vectors rows are not retired, so the original entity names stay in the vector tables;
  • tombstone: the vectors are not retired; reads already hide them through their past expires_at.

Does it reproduce on the latest release or main?

main, by reading the code; no live reproduction.

How to reproduce

  1. Give a memory an expiry in the past.
  2. Make memory_repo.retire_vectors_for_keys or reemit_embedding_rows_for_keys raise (for example, a ClickHouse insert failure) during memory.sweep_expired.
  3. Run memory.sweep_expired again: the key is not a candidate, and its vector rows stay as they were.

Expected behavior

A missed mirror is retried until it lands, for example by recording it as a projection failure that ops.projection_failures.retry can run again, and the comment states what happens.

How this was found

Reading the code while reviewing the dashboard's Health → Repairs tab, which reports a mirror: failure to the operator.

Activity

  1. added
    bug
    on Nov 7, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions