observeCurrentDb
Re-latches long-lived DAO flows on database switches and recovers the active Room pool after a reader/writer acquisition timeout. A failed query is never replayed on the same pool; publishing the replacement causes flatMapLatest to start a fresh DAO flow. Concurrent failing collectors converge on the same replacement.
Each collector stops after MAX_CONSECUTIVE_FLOW_POOL_RECOVERIES replacements without a successful emission, while the manager permits at most MAX_FLOW_POOL_RECOVERIES_PER_WINDOW successful Flow-triggered replacements per sliding POOL_RECOVERY_WINDOW_MS. The rate limit bounds how fast wedge/recover/emission cycles can create detached Room instances without ever becoming a permanent refusal; a collector that fails while the window is full can retry after backoff (see retryOnDbPoolFailure) and recover once the window clears.
A leaked pool permit does not surface as an exception at all: Room's pool logs the acquire timeout and retries forever (see requireFirstEmissionWithin), so the DAO flow simply never emits. Every latch is therefore also bounded by FLOW_FIRST_EMISSION_TIMEOUT_MS, which converts that silent stall into the same recovery path.