This commit fixes two critical issues in PostgreSQL storage: BUG 1: Legacy table cleanup causing data loss across workspaces --------------------------------------------------------------- PROBLEM: - After migrating workspace_a data from legacy table, the ENTIRE legacy table was deleted - This caused workspace_b's data (still in legacy table) to be lost - Multi-tenant data isolation was violated FIX: - Implement workspace-aware cleanup: only delete migrated workspace's data - Check if other workspaces still have data before dropping table - Only drop legacy table when it becomes completely empty - If other workspace data exists, preserve legacy table with remaining records Location: postgres_impl.py PGVectorStorage.setup_table() lines 2510-2567 Test verification: - test_workspace_migration_isolation_e2e_postgres validates this fix BUG 2: PGDocStatusStorage missing table initialization ------------------------------------------------------- PROBLEM: - PGDocStatusStorage.initialize() only set workspace, never created table - Caused "relation 'lightrag_doc_status' does not exist" errors - document insertion (ainsert) failed immediately FIX: - Add table creation to initialize() method using _pg_create_table() - Consistent with other storage implementations: * MongoDocStatusStorage creates collections * JsonDocStatusStorage creates directories * PGDocStatusStorage now creates tables ✓ Location: postgres_impl.py PGDocStatusStorage.initialize() lines 2965-2971 Test Results: - Unit tests: 13/13 passed (test_unified_lock_safety, test_workspace_migration_isolation, test_dimension_mismatch) - E2E tests require PostgreSQL server Related: PR #2391 (Vector Storage Model Isolation) |
||
|---|---|---|
| .. | ||
| api | ||
| evaluation | ||
| kg | ||
| llm | ||
| tools | ||
| __init__.py | ||
| base.py | ||
| constants.py | ||
| exceptions.py | ||
| lightrag.py | ||
| namespace.py | ||
| operate.py | ||
| prompt.py | ||
| rerank.py | ||
| types.py | ||
| utils.py | ||
| utils_graph.py | ||