LightRAG/lightrag/kg
chengjie 0bd162a416 fix: ensure finalize_share_data properly cleans up workspace locks
Why this change is needed:
The finalize_share_data() function was not properly cleaning up workspace
lock-related global variables (_sync_locks, _workspace_async_locks, and
lock registry variables). This caused stale references to remain after
finalization, leading to EOFError or BrokenPipeError when trying to
re-initialize or when processes tried to use locks after the Manager
was shut down.

How it solves it:
1. Added comprehensive cleanup of all Manager.dict proxies before Manager
   shutdown (_sync_locks, _lock_registry, _lock_registry_count,
   _lock_cleanup_data)
2. Added cleanup of per-process _workspace_async_locks dictionary
3. Reset all lock-related globals to None at end of finalization:
   - _workers, _lock_registry, _lock_registry_count, _lock_cleanup_data
   - _registry_guard, _storage_keyed_lock, _sync_locks
   - _workspace_async_locks, _earliest_mp_cleanup_time,
     _last_mp_cleanup_time

Impact:
- Prevents EOFError/BrokenPipeError in production deployments
- Enables safe re-initialization after finalization
- Critical for proper resource cleanup in multi-process deployments
- Fixes memory leaks from stale lock references

Testing:
- Added 3 comprehensive tests in test_finalization_cleanup.py
- All 23 workspace lock tests pass (17 original + 3 bug fixes + 3 finalization)
- Tests verify clean re-initialization after finalization in both
  single-process and multiprocess modes
2025-11-11 00:23:42 +08:00
..
deprecated Preserve ordering in get_by_ids methods across all storage implementations 2025-10-11 12:37:59 +08:00
__init__.py Improve storage config validation and add config.ini fallback support 2025-11-08 22:48:49 +08:00
faiss_impl.py Fix get_by_ids to return None for missing records consistently 2025-10-11 13:34:26 +08:00
json_doc_status_impl.py Add entity/relation chunk tracking with configurable source ID limits 2025-10-20 15:24:15 +08:00
json_kv_impl.py Add entity/relation chunk tracking with configurable source ID limits 2025-10-20 15:24:15 +08:00
memgraph_impl.py Remove unused chunk-based node/edge retrieval methods 2025-11-06 18:17:10 +08:00
milvus_impl.py Remove enable_logging parameter from get_data_init_lock call in MilvusVectorDBStorage 2025-10-29 09:49:59 +08:00
mongo_impl.py Remove unused chunk-based node/edge retrieval methods 2025-11-06 18:17:10 +08:00
nano_vector_db_impl.py Fix vector deletion logging to show actual deleted count 2025-10-27 14:22:16 +08:00
neo4j_impl.py Remove unused chunk-based node/edge retrieval methods 2025-11-06 18:17:10 +08:00
networkx_impl.py Remove unused chunk-based node/edge retrieval methods 2025-11-06 18:17:10 +08:00
postgres_impl.py Fix linting 2025-11-06 20:48:51 +08:00
qdrant_impl.py Add Qdrant legacy collection migration with workspace support 2025-10-30 19:16:33 +08:00
redis_impl.py Fix Redis data migration error 2025-10-21 16:27:04 +08:00
shared_storage.py fix: ensure finalize_share_data properly cleans up workspace locks 2025-11-11 00:23:42 +08:00