Skip to content

fix: harden connection lifecycle, connect budgets, and follow-up paths#74

Merged
fannnzhang merged 2 commits into
mainfrom
fix/p0-production-hardening-and-hotpath
Jul 11, 2026
Merged

fix: harden connection lifecycle, connect budgets, and follow-up paths#74
fannnzhang merged 2 commits into
mainfrom
fix/p0-production-hardening-and-hotpath

Conversation

@fannnzhang

Copy link
Copy Markdown
Contributor

Summary

Implements the high-priority production-hardening items from the deep network-stack review:

  • Connection teardown: pool eviction/remove now aborts the owned hyper connection task and clears protocol bindings so idle/max-lifetime policy actually closes sockets, not only reuse metadata.
  • Connect-stage budget: connect_timeout now covers TLS handshake and protocol binding (direct + proxy tunnel paths), not only TCP.
  • HTTP/2 readiness: temporary SendRequest unreadiness no longer treats the connection as pool-Busy and waits on the wrong signal; callers await ready() under the call path.
  • Follow-up correctness: intermediate auth/redirect/status-retry bodies are drained (capped) before the next hop so HTTP/1 can be reused; method-changing redirects strip body-describing headers (Content-Encoding, Transfer-Encoding, Expect, etc.).
  • Compression failures: decode / decompressed-size errors mark the call for connection discard so H2 is not returned to the pool as healthy.
  • WebSocket: panic-free getrandom paths; openwire-tungstenite honors max_frame_size / max_message_size.
  • Body contract: empty replayable request bodies report is_end_stream() == true.

Test plan

  • cargo test -p openwire --lib --all-features
  • cargo test -p openwire --test integration --all-features
  • cargo test -p openwire-core --lib
  • cargo test -p openwire-tungstenite --all-features
  • Updated redirect body-header unit test and event-order integration expectation for intermediate body drain

Notes

Pool sharding / lazy RequestSnapshot hot-path perf work was intentionally deferred to keep this PR focused on correctness and resource lifecycle. Follow-up PRs can take that on separately.

Close production-readiness gaps from the deep review: pool eviction now aborts
owned hyper tasks and clears bindings, connect_timeout covers TLS and protocol
binding, HTTP/2 temporary unreadiness no longer parks on the wrong wait signal,
follow-ups drain intermediate bodies and strip body headers on method-changing
redirects, decompression failures force connection discard, and WebSocket
engines honor size limits without request-path panics.
Resolve workspace clippy issues under `-D warnings` (field reassignment with
Default, collapsible match, unused mut) and apply rustfmt across touched crates.
@fannnzhang
fannnzhang merged commit 6839996 into main Jul 11, 2026
7 checks passed
@fannnzhang
fannnzhang deleted the fix/p0-production-hardening-and-hotpath branch July 11, 2026 09:10
fannnzhang added a commit that referenced this pull request Jul 11, 2026
Build on the rebased pool sharding work:

- Capture follow-up RequestSnapshot headers/extensions only when redirects,
  retries, or authenticators can rebuild the request (light mode for single-shot).
- Default clients use CachingDnsResolver (30s positive / 5s negative TTL) over
  the system resolver to cut repeated lookups under connection churn.
- Hold request-admission permits via response extensions into CallLifecycleBody,
  removing an extra BoxBody wrapper on returned responses.

Also merges pool sharding with the #74 eviction-hook teardown path.
fannnzhang added a commit that referenced this pull request Jul 11, 2026
* perf: shard the connection pool and cut hot-path allocations

Reduce lock contention and cloning on the request hot path:

- Shard the connection pool by address hash (32 shards) with a shared
  coalescing index so multi-host acquire/release no longer serializes on one
  global mutex.
- Share a single Arc<Address> across dual-stack / multi-endpoint route plans.
- Store follow-up RequestSnapshot headers and extensions behind Arc so auth
  and retry rebuilds avoid repeated full-map clones when only metadata is used.
- Reclaim ResponseBody::text() buffers via Bytes::into() when uniquely owned.

* perf: lazy snapshots, DNS cache, and thinner response body path

Build on the rebased pool sharding work:

- Capture follow-up RequestSnapshot headers/extensions only when redirects,
  retries, or authenticators can rebuild the request (light mode for single-shot).
- Default clients use CachingDnsResolver (30s positive / 5s negative TTL) over
  the system resolver to cut repeated lookups under connection churn.
- Hold request-admission permits via response extensions into CallLifecycleBody,
  removing an extra BoxBody wrapper on returned responses.

Also merges pool sharding with the #74 eviction-hook teardown path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant