Skip to content

Intermittent PostgreSQL deadlock while changing memory recall preferences #1396

Closed

Description

@tannerlinsley

The chat PostgreSQL runtime check intermittently deadlocks while changing memory recall preferences. Keep this tracked separately from the Sentry filtering fix in #1327.

AI review notes: CI run https://github.com/TanStack/tanstack.com/actions/runs/39036737723/attempts/1 failed in harness-tests/pending-runtime/memory-runtime.test.ts, case recall enabled=false controls tools in the actual assistant loop. Memories.setPreferences reached Memories.authorize at src/chat/server/memory.ts:64 and PostgreSQL returned 40P01 while locking chat_conversations. The query uses FOR UPDATE OF chat_bots, chat_conversations, chat_memberships; the test changes preferences after h.c.begin returns, while background publication may still be running.

The same commit, b092eedc05c28a346a5d44e6ee23c3c7cfbc6a9f, passed a single diagnostic CI rerun. An isolated local PostgreSQL 17 database also passed the memory file's 9 tests and the full runtime suite's 278 tests across 35 files. These passes do not establish the cause or prove the deadlock harmless. No database code changed in #1327.

Next: capture both transactions from PostgreSQL's deadlock log, reproduce their lock ordering deterministically, and test the correction without weakening authorization or hiding failures with blanket retries. Interaction with the activity outbox's foreign-key locks is a hypothesis, not a confirmed diagnosis.

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