Skip to content

fix(balance): clear cached P2C ready index after a discovery removal - #1

Open
clemenslosbichler-cloud wants to merge 3 commits into
cg-base-874from
cg-head-874
Open

clemenslosbichler-cloud wants to merge 3 commits into
cg-base-874from
cg-head-874

Conversation

@clemenslosbichler-cloud

Copy link
Copy Markdown
Owner

Recreation of tower-rs#874 on a fork, for testing an automated code reviewer against real code. Not a contribution and not intended to be merged. Upstream: tower-rs#874

`Balance::poll_ready` caches the P2C-selected endpoint as a numeric
`ready_index`. When a later `poll_ready` processes a `Change::Remove`, it
calls `ReadyCache::evict`, which removes from the ready set with `swap_remove`
and can move a different endpoint into the slot the cached index points at.
The stale index was then revalidated by `check_ready_index` and dispatched to
by `call`, silently bypassing the P2C choice during endpoint churn.

Clear `ready_index` whenever a removal evicts a service, so the next
`poll_ready` re-runs P2C over the current ready set. Also correct the
`poll_ready` comment that wrongly claimed discovery updates cannot disturb the
order of existing ready services.
…s#856)

Drive a balancer to cache a P2C selection, remove that endpoint so eviction
swap-moves a different endpoint into the cached slot, and assert the next
request is routed by a fresh P2C selection rather than to the swapped-in
endpoint. Uses a fed-on-demand Discover (deterministic ready-set order) and a
zero RNG (deterministic P2C sampling).
Break the `changes.borrow_mut().push_back(..)` chains onto multiple lines to
satisfy rustfmt's chain_width, fixing the `style` CI job.
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