You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP/2 connections leak when reused_http_session() races with release_http_session() #1024
reused_http_session() can put an h2 connection into InUsePool twice. When the connection goes idle, only one entry is removed. The other stays in InUsePool, which has no idle timer, so Pingora never closes the connection.
How it happens:
Task A calls reused_http_session(), which takes connection C out of InUsePool.
Stream B on C ends. release_http_session() can't find C, and C still has other streams, so it puts C back.
Task A puts C back too, without release_lock or a duplicate check. Now there are two entries.
When C goes idle, one entry moves to the idle pool and times out. The other keeps C open.
Pingora version: 0.9.0, still present on main Rust version: 1.89 Operating system version: Debian 12
Steps to reproduce
Run test_reused_http_session_no_duplicate_in_use_entry from #1025 without the fix. It forces the race on every run.
I also reproduced it under load: 256 concurrent tasks in bursts against a local h2c upstream that never closes idle connections, with a 3 s idle_timeout.
Expected results
No connections left open after idle_timeout.
Observed results
The test finds one leftover entry in InUsePool. The load test left 4 to 10 sockets open in every run.
Additional context
#1025 fixes it by taking release_lock and removing the old entry before the insert.
Activity