Skip to content

Duplicate key errors on mem0migrations table #3687

@dcr1lud

Description

@dcr1lud

Hi mem0 team,

We are experiencing persistent duplicate key errors on the mem0migrations table when running mem0ai, even with only a single pod or process. The error log is as follows:

mem0.vector_stores.pgvector - INFO - Inserting 1 vectors into collection mem0migrations
mem0.vector_stores.pgvector - ERROR - Error occurred: duplicate key value violates unique constraint "mem0migrations_pkey"

This happens even when all migrations have already been applied and no other processes are writing to the table. It appears that mem0ai’s migration/version logic is not idempotent or is re-attempting inserts unnecessarily.

This issue occurs even in single-instance deployments. It would be helpful to have the migration/versioning logic reviewed to ensure it is fully idempotent and does not cause duplicate key errors.
Alternatively, please consider adding an environment variable (e.g., MEM0_SKIP_MIGRATIONS) to allow users to disable all runtime migration logic in mem0ai.

Thank you

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