Nordix / hiredis-cluster

C client library for Valkey/Redis Cluster. This project is used and sponsored by Ericsson. It is a fork of the now unmaintained hiredis-vip.
BSD 3-Clause "New" or "Revised" License
87 stars 42 forks source link

Use correct dict-key format during the use of CLUSTER NODES #147

Closed bjosv closed 1 year ago

bjosv commented 1 year ago

node->addr is used as key in the nodes dict in the cluster context. During ASK redirects the key is expected to be ip:port and this change can fix a problem of creating node doublets is some scenarios.

Both the add node API and CLUSTER SLOTS also uses ip:port as the key.

Previously the key could be: 127.0.0.1:30004@31004,,shard-id=69bc080733d1355567173199cff4a6a039a2f024 instead of: 127.0.0.1:30004

PR includes 2 new tests using CLUSTER NODES.

zuiderkwast commented 1 year ago

(port 7400) SEND "bar"
Simulated server exited with status 255

      Start 21: timeout-handling-test
21/26 Test #21: timeout-handling-test ...........................   Passed    1.06 sec
      Start 22: connect-error-using-cluster-nodes-test
22/26 Test #22: connect-error-using-cluster-nodes-test ..........***Failed    0.02 sec
JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this) at ./simulated-redis.pl line 115, <> line 3.
bjosv commented 1 year ago

Nice. In recent redis versions, it's possible to use hostname in redirects and cluster slots. Not sure about cluster nodes. I guess we should add some test or todos.

Added #148 regarding adding tests.