Skip to content

Retire stateful connections without reset proof - #103

Merged
mjc merged 5 commits into
nntpp-27-cancel-safe-stateful-forwardingfrom
nntpp-28-stateful-connection-lifecycle
Sep 11, 2026
Merged

Retire stateful connections without reset proof#103
mjc merged 5 commits into
nntpp-27-cancel-safe-stateful-forwardingfrom
nntpp-28-stateful-connection-lifecycle

Conversation

@mjc

@mjc mjc commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • classify client and backend exits explicitly in the stateful loop
  • finalize every pooled lease on success and error paths
  • preserve clean completed responses while retiring dirty or incomplete connections

Branch-added tests

  • Concurrent stateful clients exercise pooled connection retirement and verify the pool does not retain closed sockets.
  • Pool status coverage checks that explicit retirement removes the object without shrinking unrelated capacity.
  • Response-transfer cases distinguish clean completed client disconnects from queued bytes, backend EOF, and I/O failure.

Copilot AI lite review requested due to automatic review settings September 5, 2026 21:48
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 03b610f5-3d09-473b-aae5-820114a25efb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new stateful error-finalization path has a non-exhaustive match (won’t compile) and the hybrid/stateful error wrapping can misclassify client disconnect/write errors as backend errors, impacting runtime logging/behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR refines stateful connection lifecycle handling so pooled backend leases are always finalized, and backend reuse/retirement decisions are based on explicit session-exit classification and “clean vs dirty” response-transfer outcomes.

Changes:

  • Adds explicit stateful session exit/disposition tracking and uses it to decide whether to reuse or retire pooled backend connections.
  • Adjusts response-transfer semantics so a completed response with no queued backend bytes can keep the backend reusable even if the final client write fails.
  • Prevents retired deadpool objects from re-entering the idle pool by taking the object before dropping, and extends pool-status coverage in tests.
File summaries
File Description
src/session/response_transfer.rs Updates backend reuse decision for ClientWrite when the connection is otherwise reusable, and updates tests accordingly.
src/session/handlers/stateful.rs Introduces explicit exit/disposition types and finalizes pooled connection guards on all paths (but currently has a blocking error-path issue).
src/session/handlers/hybrid.rs Centralizes backend lease finalization via a new finalize() helper and applies stateful-loop disposition to pooled lease retirement.
src/pool/provider.rs Ensures retired connections cannot be returned to deadpool by dropping Object::take(conn) and extends test assertions around pool size.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/session/handlers/stateful.rs
Comment thread src/session/handlers/hybrid.rs Outdated
@mjc
mjc force-pushed the nntpp-28-stateful-connection-lifecycle branch from d6fbd37 to 4f3244a Compare September 5, 2026 23:28
Repository owner deleted a comment from coderabbitai Bot Sep 11, 2026
@mjc
mjc merged commit 7afa6cc into nntpp-27-cancel-safe-stateful-forwarding Sep 11, 2026
8 checks passed
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.

2 participants