Reentrant logging deadlock causes worker termination with SIGKILL
criticalavailabilityUpdated May 21, 2025(via Exa)
Technologies:
How to detect:
Gunicorn versions < 20.1 experience a RuntimeError when multiple worker processes attempt to write to stderr simultaneously, triggering reentrant or recursive logging that causes logging deadlocks. Workers are forcefully killed with signal 9 (SIGKILL), leading to intermittent application downtime despite normal CPU and memory usage.
Recommended action:
Upgrade Gunicorn to version 21.2.0 or later (23.0.0 recommended). Replace direct stderr logging with logging.StreamHandler(sys.stdout) in Python code. Configure max_requests (e.g., 1000) and max_requests_jitter (e.g., 100) to recycle workers periodically. Consider reducing worker count during peak concurrency. Monitor stderr and worker signals even when application logs appear normal.