Skip to content

fix: SQLite writes lack retry logic under concurrent load #5

@KJ-AIML

Description

@KJ-AIML

Problem

memctrl/store.py sets busy_timeout=30s but has no exponential backoff retry. If two agents (CLI + MCP server) write simultaneously, the second gets database is locked and fails permanently.

Fix

Add a _retry_write() helper with 3 attempts (50ms / 200ms / 500ms). Wrap all write operations:

  • insert_memory
  • delete_memory
  • update_memory
  • clear_memories
  • insert_tree_node
  • save_provenance

Acceptance

Add test_concurrent_writes_dont_crash using threading to verify no unhandled OperationalError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions