fix: close blob seq sqlite migration connection - #1804
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that the SQLite database connection in _fix_blob_seq_ids is properly closed by wrapping sqlite3.connect with contextlib.closing. Additionally, a unit test has been added to verify that the connection is indeed closed after the migration. There are no review comments, and I have no further feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR addresses ResourceWarning noise under Python 3.13 by ensuring the temporary sqlite3 connection used by Chroma’s _fix_blob_seq_ids pre-open migration is explicitly closed after probing/migrating.
Changes:
- Wrap the migration’s sqlite connection with
contextlib.closing(...)to guaranteeconn.close()is called. - Add a regression test that monkeypatches the sqlite connection factory to confirm the connection close path is exercised.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
mempalace/backends/chroma.py |
Ensures the _fix_blob_seq_ids sqlite3 connection is explicitly closed after the migration probe/work. |
tests/test_backends.py |
Adds a regression test verifying the migration code path closes the sqlite connection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Why
Python sqlite3 connection context managers commit or roll back, but they do not close the connection. Under Python 3.13 warning probes, the release candidate stack surfaced ResourceWarning noise from this pre-open migration path.
Validation
uv run --python 3.13 pytest tests/test_backends.py::test_fix_blob_seq_ids_closes_sqlite_connection tests/test_backends.py::test_fix_blob_seq_ids_converts_blobs_to_integers tests/test_backends.py::test_fix_blob_seq_ids_writes_marker_when_already_integer -qPYTHONTRACEMALLOC=10 uv run --python 3.13 pytest tests/test_sync.py -q -W default::ResourceWarning -W error::pytest.PytestUnraisableExceptionWarninguv run --python 3.13 ruff check mempalace/backends/chroma.py tests/test_backends.pyuv run --python 3.13 ruff format --check mempalace/backends/chroma.py tests/test_backends.pygit diff --check