You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tree-wide cache lock: cross-thread deadlock and per-thread dependency builds #569
The caller holds the tree lock inside create; the worker blocks on the same lock for B. The same lock also serialises unrelated cold creations across every request in the tree.
2. Concurrent cold misses build dependencies once per thread
resolve() of the dependencies runs outside the lock (cache_registry.py:41). 8 threads resolving a cached Svc(conn: Conn) with transient Conn: one Svc, 8 Conn, 7 discarded without finalizers. Same on 3.14t. design-decisions.md only promises one instance.
Options
Per-item lock (a lock per CacheItem, created with the item): fixes the deadlock and the serialisation; deadlock remains possible only for real cycles, which are already errors. Cost: one lock per cached item, not per request.
Resolve dependencies inside the (per-item) lock: fixes item 2 at the cost of holding the lock across dependency construction.
Or document item 2 as accepted behaviour.
Needs a decision and a G15 (concurrent first resolve) measurement before implementation. Failing tests first (the deadlock test needs a timeout).
Activity
fix: use threading.RLock, document the concurrent cycle limit, add G7b (
fix!: lock each cached factory on its own and build its dependencies …
fix: use threading.RLock, document the concurrent cycle limit, add G7b (
fix!: lock each cached factory on its own and build its dependencies …