* fix(roms): read filter values with .all() so the GC never frees the cursor
Looping over the filter-values Result directly makes SQLAlchemy 2.1 memoize
an iterator closure that captures the Result, which puts the CursorResult,
its execution context and the mariadb cursor in a reference cycle. The
cyclic GC then frees them on whatever thread triggers a collection, and
under concurrent gallery requests that segfaults the mariadb connector
(1.1.14, Python 3.14) inside the pool checkout. .all() never builds that
closure, so nothing is left for the GC.
* fix(roms): address pr-ready code review
* style(roms): pr-ready polish
* fix(db): read every iterated query result with .all()
The same reference cycle that segfaulted the filter values also hits smart
collection matching on every save, the screenshot binding check, playlist and
favourite adds, the recommendation reads and the stopword probe. The IGDB
related-games stream keeps yield_per and closes its Result with a with block.
A source scan test now fails on any Result iterated directly.
* fix(roms): address Greptile review
Keep gc.garbage entries that predate the filter-values cursor test: only the
objects this test collects are inspected and removed, so a runner that already
saves garbage keeps its list intact (Greptile, test_rom_facets.py).
* pr-ready: code-review fixes
Keep a generator's begin_session open until it finishes, read the
streamed IGDB scan by partition, and widen the iterated-Result guard to
names, unpacking, yield from and iterating methods.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* pr-ready: simplify
Share the app-source AST scan between the two guard tests, fold the
generator session's two branches into one nullcontext, and drop the
call-site comment the guard test already carries.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(db): flag iterated legacy session.query() results
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
As recommended by SQLAlchemy [1], this change makes a single
instantiation of the database engine and session maker, instead of one
entity per handler.
It also uses the provided `URL` constructor to better define the
database URL structure.
[1] https://docs.sqlalchemy.org/en/20/core/connections.html#basic-usage