LightRAG/tests
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
..
test_aquery_data_endpoint.py Fix conditional logic in streaming response parser of unit test 2025-09-27 21:43:46 +08:00
test_curl_aquery_data.sh Fix linting 2025-10-06 04:57:11 +08:00
test_finalization_cleanup.py fix: ensure finalize_share_data properly cleans up workspace locks 2025-11-11 00:23:42 +08:00
test_graph_storage.py Initialize shared storage for all graph storage types in graph unit test 2025-11-06 19:24:12 +08:00
test_lightrag_ollama_chat.py clean comments and unused libs 2025-02-18 21:12:06 +01:00
test_postgres_retry_integration.py Refactor PostgreSQL retry config to use centralized configuration 2025-10-10 03:44:13 +08:00
test_workspace_lock_bugfixes.py fix: ensure finalize_share_data properly cleans up workspace locks 2025-11-11 00:23:42 +08:00
test_workspace_locks.py style: apply code formatting to pass pre-commit checks 2025-11-11 00:10:54 +08:00