Skip to content

fix: allow HashClient to remove healthy servers - #670

Open
0x5t4l1n wants to merge 1 commit into
pinterest:masterfrom
0x5t4l1n:fix/remove-healthy-hash-server
Open

0x5t4l1n wants to merge 1 commit into
pinterest:masterfrom
0x5t4l1n:fix/remove-healthy-hash-server

Conversation

@0x5t4l1n

Copy link
Copy Markdown

Problem

Calling HashClient.remove_server() on a configured, healthy server raises KeyError: the implementation unconditionally pops the server from _failed_clients, even when there has never been a connection failure. Consequently, callers cannot take a healthy node out of rotation using this method.

For example:

client = HashClient([("127.0.0.1", 11211), ("127.0.0.1", 11212)])
client.remove_server(("127.0.0.1", 11211))  # currently raises KeyError

Change

Make removal of the optional failure record tolerate an absent entry. Remove the node from the hasher before updating failure/dead bookkeeping, so an unknown node cannot accidentally be scheduled for reactivation after an unsuccessful removal.

Retain the existing dead-timeout recovery policy. Tests verify routing to the remaining server and reactivation after the timeout.

Validation

  • Reproduced the original KeyError for tuple addresses, separate host/port arguments, and Unix socket paths.
  • Add six regression cases for those three address forms with pooling enabled and disabled, plus an unknown-node bookkeeping test.
  • 501 unit tests pass on Linux / Python 3.13.12.
  • Flake8, Black (--target-version py39), mypy for both changed files, and git diff --check pass.

Local testing used the existing isolated environment with zstd==1.5.7.2; live-server integration and benchmark tests were deselected by the repository's unit-test configuration. Black's target override is needed because the repository lists py314 while pinning Black 24.4.2, which does not recognize that target. The six existing full-package mypy errors in the untouched AWS client module were previously confirmed on clean master; no dependency or CI configuration changes are included here.

This branch starts directly from master and is independent of #669.

@0x5t4l1n
0x5t4l1n requested review from a team and jparise as code owners October 24, 2026 14:06
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