Skip to content

Added handling to "?" and NULL hostnames in CLUSTER SLOTS - #104

Merged
barshaul merged 2 commits into
amazon-contributing:mainfrom
barshaul:fix_cluster_slots
Jan 25, 2024
Merged

barshaul merged 2 commits into
amazon-contributing:mainfrom
barshaul:fix_cluster_slots

Conversation

@barshaul

Copy link
Copy Markdown

Based on the description of CLUSTER SLOTS (https://redis.io/commands/cluster-slots/):

The preferred endpoint, along with the port, defines the location that clients should use to send requests for a given slot. A NULL value for the endpoint indicates the node has an unknown endpoint and the client should connect to the same endpoint it used to send the CLUSTER SLOTS command but with the port returned from the command. This unknown endpoint configuration is useful when the Redis nodes are behind a load balancer that Redis doesn't know the endpoint of. Which endpoint is set as preferred is determined by the cluster-preferred-endpoint-type config. An empty string "" is another abnormal value of the endpoint field, as well as for the ip field, which is returned if the node doesn't know its own IP address. This can happen in a cluster that consists of only one node or the node has not yet been joined with the rest of the cluster. The value ? is displayed if the node is incorrectly configured to use announced hostnames but no hostname is configured using cluster-announce-hostname. Clients may treat the empty string in the same way as NULL, that is the same endpoint it used to send the current command to, while "?" should be treated as an unknown node, not necessarily the same node as the one serving the current command.

@shachlanAmazon shachlanAmazon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: if we add tests only to one cluster implementation, it's better to add to the async connection, not the sync.

@barshaul
barshaul force-pushed the fix_cluster_slots branch 2 times, most recently from 25e725f to ae43cff Compare January 25, 2024 07:26
@barshaul

barshaul commented Jan 25, 2024

Copy link
Copy Markdown
Author

minor: if we add tests only to one cluster implementation, it's better to add to the async connection, not the sync.

@shachlanAmazon
Added tests for async_cluster too, and moved the test that is the exactly the same for sync and async (test_cluster_async_cannot_connect_to_server_with_unknown_host_name) to the test_cluster_async file.

@barshaul
barshaul merged commit 9e51226 into amazon-contributing:main Jan 25, 2024
@barshaul
barshaul deleted the fix_cluster_slots branch January 25, 2024 08:42
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