Skip to content

fix: Postgres reorganizer crashes due to missing graph-store methods #2272

Description

@Kwizii

Bug Description

When MOS_ENABLE_REORGANIZE=true and the graph backend is PostgresGraphDB, the background structure optimization thread crashes because several methods exist on Neo4jGraphDB but are missing or incompatible on PostgresGraphDB.

Observed runtime error:

AttributeError: 'PostgresGraphDB' object has no attribute 'node_not_exist'

After that is patched, the next failures are typically get_memory_count, get_edges, or edge_exists(..., direction=..., user_name=...).

Method Used by Impact
node_not_exist(scope, user_name) reorganizer.optimize_structure Thread crash
get_memory_count(memory_type, user_name) reorganizer.optimize_structure AttributeError
get_edges(id, type, direction, user_name) handler._resolve_in_graph, manager._inherit_edges MERGED_TO merge cannot inherit edges
edge_exists(..., direction=..., user_name=...) reorganizer / handler / manager TypeError or wrong semantics
get_structure_optimization_candidates(..., user_name=...) reorganizer Ignores per-user scope
search_by_fulltext(...) recall / searcher AttributeError on keyword recall path

How to Reproduce

  1. Run MemOS Product API with Postgres graph backend and MOS_ENABLE_REORGANIZE=true.
  2. Add memories via /product/add until the reorganizer background thread runs structure optimization.
  3. Observe logs from _run_structure_optimization_periodically / optimize_structure.

Environment

  • Python: 3.11
  • Operating System: Linux (Docker)
  • MemOS: main branch
  • Graph backend: postgres + pgvector
  • MOS_ENABLE_REORGANIZE=true

Additional Context

  • Postgres backend should expose the same graph-store interface used by tree text memory reorganizer and handler so redundant-memory merge can create MERGED_TO edges without crashing.
  • I am willing to implement this myself and have a patch ready on fork branch fix/postgres-reorganizer-compat (PR fix: PostgresGraphDB reorganizer/handler compatibility #2273).

Metadata

Metadata

Labels

ai:failedAI task failed | AI 任务失败area:databasegraph_db + vector_db | 图数据库与向量数据库status:in-progressSomeone or AI is working on it | 人工或 AI 正在处理types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions