Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support string slot values in CLUSTER SHARD response #56

Merged
merged 2 commits into from
Feb 11, 2024

Conversation

DanielKulesza
Copy link
Contributor

@DanielKulesza DanielKulesza commented Jan 6, 2024

It appears Redis 7.0.14 returns slot values in the CLUSTER SHARDS command response that are represented as strings.

With string slots, nebulex_redis_adapter fails to correctly set up redis cluster shards in the client. This results in consistent MOVED responses.

Redis 7.0.14 responses

<REDACTED_IP>:6379> INFO
# Server
redis_version:7.0.14
...

<REDACTED_IP:6379> CLUSTER SHARDS
 1) 1) "slots"
    2) 1) "4096"
       2) "5119"
    3) "nodes"
    4) 1)  1) "id"
           2) <REDACTED_ID>
           3) "port"
           4) (integer) 11041
           5) "ip"
           6) <REDACTED_IP>
           7) "endpoint"
           8) <REDACTED_IP>
           9) "role"
          10) "replica"
          11) "replication-offset"
          12) (integer) 1743874443
          13) "health"
          14) "online"
...

Redis 7.2.2 responses


localhost:6380> INFO
# Server
redis_version:7.2.2
...

localhost:6380> CLUSTER SHARDS
1) 1) "slots"
   2) 1) (integer) 10923
      2) (integer) 16383
   3) "nodes"
   4) 1)  1) "id"
          2) "fb359c5f566b29a0d3859fee3ca8c8c12f3ece79"
          3) "port"
          4) (integer) 6382
          5) "ip"
          6) "10.10.10.13"
          7) "endpoint"
          8) "10.10.10.13"
          9) "role"
         10) "master"
         11) "replication-offset"
         12) (integer) 266
         13) "health"
         14) "online"
...

Updating the handler for CLUSTER SHARDS response to support both string or integer slot values.

Note:
Possibly related Redis fix: redis/redis@4031a18

@@ -316,4 +317,7 @@ defmodule NebulexRedisAdapter.RedisCluster.ConfigManager do
end

# coveralls-ignore-stop

defp maybe_convert_to_integer(value) when is_binary(value), do: String.to_integer(value)
defp maybe_convert_to_integer(value), do: value
Copy link
Owner

Choose a reason for hiding this comment

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

LGTM, but let's move the # coveralls-ignore-stop above to skip these new lines (or you can also add a test, but I think it is just a simple thing).

@cabol
Copy link
Owner

cabol commented Jan 7, 2024

Thanks for the fix. Overall LGTM, I just added a comment. Also, you should rebase since I merged your other PR. Thanks.

@cabol cabol force-pushed the master branch 6 times, most recently from 3699676 to c6fee05 Compare February 11, 2024 15:19
@cabol cabol merged commit fa0dfcc into cabol:master Feb 11, 2024
0 of 5 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.

None yet

2 participants