Commit 1e9764a
authored
fix: offload blocking I/O in health checks to prevent event loop freezes (#1537)
The background health checker was running synchronous blocking I/O
directly on the asyncio event loop every 10 seconds, freezing Uvicorn
and preventing it from responding to HTTP requests — including
Kubernetes health probes. This caused pods to get killed and restart
in a crash loop in production.
Changes:
- Switch _check_redis_health() from sync redis to redis.asyncio
- Wrap psutil.cpu_percent(interval=0.1) in asyncio.to_thread()
- Wrap all sync engine.connect() DB calls in asyncio.to_thread()
- Also fix blocking calls in /health/cpu, /health/db,
/health/consensus, and /metrics HTTP endpoints1 parent 74e4d21 commit 1e9764a
1 file changed
Lines changed: 245 additions & 220 deletions
0 commit comments