fix: log warning when managed_backends lock is poisoned during routing

When the managed_backends RwLock is poisoned (indicating a panic in a thread
that held the lock), log a warning and skip the managed backend lookup,
falling back to the single backend. This improves observability of lock
poisoning events.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
whit3rabbit
2026-04-08 13:23:02 -05:00
co-authored by Claude Sonnet 4.6
parent b125920a26
commit af80237cf3
+12 -9
View File
@@ -174,16 +174,19 @@ impl AppState {
.or_else(|| {
// Check managed backends (SQLite-backed, zero-restart)
self.shared.as_ref().and_then(|s| {
s.managed_backends
let guard = s.managed_backends
.read()
.ok()?
.get(&backend_name)
.map(|(_, client)| {
let mut state = self.clone();
state.backend = client.clone();
state.backend_name = backend_name.clone();
state
})
.ok()
.or_else(|| {
tracing::warn!("managed_backends RwLock is poisoned; skipping managed backend lookup");
None
})?;
guard.get(&backend_name).map(|(_, client)| {
let mut state = self.clone();
state.backend = client.clone();
state.backend_name = backend_name.clone();
state
})
})
})
.unwrap_or_else(|| self.clone());