test(repair): close ChromaBackend in _seed_palace to release Windows file locks
The helper opened a chromadb PersistentClient via ChromaBackend and never closed it, leaving rust-side SQLite/HNSW file locks alive after the helper returned. On Windows that blocks the in-place archive rename inside rebuild_from_sqlite with WinError 32 on data_level0.bin, causing test_rebuild_from_sqlite_in_place_archives_when_opted_in and test_rebuild_from_sqlite_raises_on_upsert_failure to fail in the test-windows CI job. No test consumes the returned collection, so closing the backend in a try/finally is safe and drops the return.
This commit is contained in:
+14
-10
@@ -696,20 +696,24 @@ def test_max_seq_id_rollback_on_verification_failure(tmp_path, monkeypatch):
|
|||||||
def _seed_palace(palace_path, collection_name, rows):
|
def _seed_palace(palace_path, collection_name, rows):
|
||||||
"""Build a real chromadb palace at ``palace_path`` and add ``rows``.
|
"""Build a real chromadb palace at ``palace_path`` and add ``rows``.
|
||||||
|
|
||||||
``rows`` is a list of ``(id, document, metadata)`` tuples. Returns
|
``rows`` is a list of ``(id, document, metadata)`` tuples.
|
||||||
the populated collection so callers can assert on the writer's view
|
|
||||||
of state before the SQLite read.
|
|
||||||
"""
|
"""
|
||||||
from mempalace.backends.chroma import ChromaBackend
|
from mempalace.backends.chroma import ChromaBackend
|
||||||
|
|
||||||
backend = ChromaBackend()
|
backend = ChromaBackend()
|
||||||
col = backend.create_collection(str(palace_path), collection_name)
|
try:
|
||||||
col.upsert(
|
col = backend.create_collection(str(palace_path), collection_name)
|
||||||
ids=[r[0] for r in rows],
|
col.upsert(
|
||||||
documents=[r[1] for r in rows],
|
ids=[r[0] for r in rows],
|
||||||
metadatas=[r[2] for r in rows],
|
documents=[r[1] for r in rows],
|
||||||
)
|
metadatas=[r[2] for r in rows],
|
||||||
return col
|
)
|
||||||
|
finally:
|
||||||
|
# Release chromadb's rust-side SQLite/HNSW file locks before the
|
||||||
|
# caller proceeds. Without this, an in-place rebuild on Windows
|
||||||
|
# fails with WinError 32 on data_level0.bin during the archive
|
||||||
|
# rename (cf. PR #1310 test-windows job).
|
||||||
|
backend.close()
|
||||||
|
|
||||||
|
|
||||||
def test_extract_via_sqlite_returns_all_rows_with_metadata(tmp_path):
|
def test_extract_via_sqlite_returns_all_rows_with_metadata(tmp_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user