tests: close leaked sqlite connections — ResourceWarning flood in CI test job #618
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CI's test job (e.g. run 773 jobstep 5) floods
ResourceWarning: unclosed database in <sqlite3.Connection>+Enable tracemalloc…hint lines — read as crash noise, actually GC'd never-closed connections. Full-suite repro (14,099 passed, 25m36s, exit 0 — no hang) attributes 38 warnings to:src/zot/db.py:772— 4× unclosed connections (zot module close path)tests/zot/—test_extract.py::TestExtractorRealDb::test_export_provenance_real(4×),test_duck.py:242,test_db.py:157,test_ops.py::TestFixKeys::test_runstests/api/test_server.py(Auth + Pipelines, 2× each) andtest_routes_coverage.py(2× each)tests/cli/test_llm_exercise.py::TestIndexComments::test_default_collection_is_comments(2×) — Store opened without close (touched by #595)tests/rec/test_main.py,tests/aco/test_dag.py(1× each); plus coverage's ownsqlitedb.py(xdist artifact, upstream)Fix: close/context-manage every connection (fixtures + zot db paths); then gate regressions with
filterwarnings = ["error::ResourceWarning", "ignore::ResourceWarning:coverage.*"]in pyproject if the suite stays green under it — otherwise document why not.Fixed in
cc418ce. Four tracemalloc-verified leaks closed (zot Db.init on schema-parity raise; two zot test fixtures; cli comments lookup-cache connection) — most of this issue's per-test attributions were GC-timing misattribution across xdist workers. Gate landed:filterwarnings = ["error::ResourceWarning", "ignore::ResourceWarning:coverage.*"]; the commit's pre-commit hook ran the full suite green under the gate. Scoped tracemalloc reruns: 0 ResourceWarnings (was 22+ in tests/zot alone). The unrelated live-data failure surfaced en route is tracked as #623. Report: [.superpowers/sdd/p618-report.md] (session artifact).