Refactor in-flight requests tracking (Continues #7281 / Fixes #7277)#1
Closed
pauloappbr wants to merge 1 commit intou5surf:issue-7277from
Closed
Refactor in-flight requests tracking (Continues #7281 / Fixes #7277)#1pauloappbr wants to merge 1 commit intou5surf:issue-7277from
pauloappbr wants to merge 1 commit intou5surf:issue-7277from
Conversation
…server#7277) This refactors the initial approach in PR caddyserver#7281, replacing the UsagePool with a dedicated package-level map protected by a sync.RWMutex. This addresses maintainer feedback, avoids double-counting bugs, and ensures that draining upstreams are correctly exposed via the admin API across config reloads without leaking memory. Co-authored-by: Y.Horie <u5.horie@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assistance Disclosure
I consulted an AI assistant (Gemini) to help refactor the UsagePool logic into the
sync.RWMutexmap approach suggested by @mholt, and to ensure the Git co-authoring flow was handled correctly. I fully reviewed, authored the final structure, and verified the code's correctness.Hey @u5surf and @mholt!
I saw PR caddyserver#7281 was stalled for a bit, but the feature requested in caddyserver#7277 is incredibly useful for connection draining observability.
I took the liberty to implement the approach suggested by @mholt in the review comments. Instead of hacking
UsagePool, this implementation uses a lightweight, package-levelmap[string]uintprotected by async.RWMutex.Changes:
inflightHostsUsagePool logic.inFlightRequestsmap to track requests during the proxy loop securely.admin.goto expose these draining hosts alongside the static hosts in/reverse_proxy/upstreams.@u5surf, I've added you as a co-author since this builds directly upon your initial work and test cases. If you merge this into your branch, it will automatically update your main PR on the Caddy repo!