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

"cluster info" command #100

Closed SS-TruMinds closed 2 years ago

SS-TruMinds commented 2 years ago

Hi,

We are trying to issue 'cluster info' as follows:

int status = redisClusterAsyncCommand(cc, clusterInfoCallback, (char *)"THE_ID", "CLUSTER INFO");

This returns REDIS_ERR, with cc->err set to "Parse command error. Cmd type: 0, state: 5, break position: 15."

What could be the issue here?

Thank you.

zuiderkwast commented 2 years ago

Hi!

Probably hiredis-cluster tries to figure out to which node to send the command. Most commands contain a key and the command is sent to the node that has the key. My guess is that there is no such case for CLUSTER INFO.

Here is a workaround: Send the command to a specific node using redisClusterAsyncCommandToNode, where the node is chosen in advance. For CLUSTER INFO it can be any node in cc->nodes. (TODO: Add this to README, with examples how to iterate over it.)

In this test suite there are examples of sending commands to specific nodes and to all nodes in the cluster: https://github.com/Nordix/hiredis-cluster/blob/master/tests/ct_specific_nodes.c

SS-TruMinds commented 2 years ago

Thank you.

In the meantime, we tried redisClusterAsyncCommandToNode and it worked, so that is how we will proceed.

Thank you for the support.