mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
The database phase had the same shape the K-profile phase did: _find_ archive, _find_spool, the usage dedupe and _restore_settings are all one SELECT per row or per key, interleaved with autoflushed INSERTs, inside a single open write transaction. A few thousand archives plus a full usage history plausibly passes the 15 s busy_timeout, and every concurrent writer in the app fails with "database is locked" until it finishes. Each category now commits before the next starts. The id maps are plain dicts in memory and the session is expire_on_commit=False, so the ordering tolerates it. The cost is that a later failure no longer rolls back an earlier category, so a tally is recorded only after its category commits and run_restore reports the categories already on disk instead of an empty result - the same correction the K-profile split needed.