#511 [ENGINE/Race] Circuit breaker storage singleton missing lock

closed high Created 2025-12-17 14:58 · Updated 2025-12-17 15:52

Description

Edit
**File:** engine/config.py:337-365 **Problem:** Missing lock for singleton initialization. Two threads could both see None, both create storage instances, causing connection pool leaks. **Severity:** HIGH **Fix:** Use double-check locking pattern: ```python _cb_storage_lock = threading.Lock() def _get_circuit_breaker_storage() -> PostgresStorage: global _circuit_breaker_storage if _circuit_breaker_storage is not None: return _circuit_breaker_storage with _cb_storage_lock: if _circuit_breaker_storage is not None: return _circuit_breaker_storage _circuit_breaker_storage = PostgresStorage(...) return _circuit_breaker_storage ``` **Impact:** Connection leaks on worker startup race.

Comments

Loading comments...

Context

Loading context...

Audit History

View All
Loading audit history...