Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(library-deletion): harden lock and race-log contracts (#5639)

Chanhyo Jung2b39a8d000ac
diff --git a/tests/research_library/deletion/services/test_document_deletion.py b/tests/research_library/deletion/services/test_document_deletion.py
index 5fbcf79c4d..c6d2ea92f8 100644
--- a/tests/research_library/deletion/services/test_document_deletion.py
+++ b/tests/research_library/deletion/services/test_document_deletion.py
@@ -137,11 +137,26 @@ class TestDocumentDeletionServiceDeleteDocument:
mock_session.rollback.assert_called_once()
mock_session.commit.assert_not_called()
mock_purge.assert_not_called()
- mock_info_log.assert_called_once_with(
- "Document doc-race... was already removed by a concurrent "
- "delete request"
+ assert mock_info_log.call_count == 1
+ assert "doc-race..." in mock_info_log.call_args.args[0]
+
+ def test_document_delete_lock_is_non_reentrant(self):
+ """The same thread must not acquire a document delete lock twice."""
+ from local_deep_research.research_library.deletion.services.document_deletion import (
+ _document_delete_locks,
+ _hold_document_delete_lock,
)
+ lock_key = ("testuser", "doc-lock-contract")
+ with _hold_document_delete_lock(*lock_key):
+ lock = _document_delete_locks[lock_key]
+ reacquired = lock.acquire(blocking=False)
+ try:
+ assert reacquired is False
+ finally:
+ if reacquired:
+ lock.release()
+
def test_serializes_same_document_deletes_across_service_instances(self):
"""The second request must wait until the first deletion fully exits."""
first_service = DocumentDeletionService(username="testuser")