question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cluster node is automatically disconnected when it has no slots

See original GitHub issue

I tried this code and I only see any logs in the then or catch

logger.debug('%s MEET Sending: %s', id, cmd);
// Tried also redis.cluster('meet', ip, port).then ...
redis.cluster(['meet', ip, port]).then((response) => {
        logger.info('%s MEET %s', id, response);
        return response;
    }).catch((err) => {
        logger.error(err, '%s Cannot MEET', id);
        return {error: true};
    });

It would be nice to have some examples too.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
luincommented, May 15, 2019

It looks like that ioredis does not stay connected because there are no slots.

Yes, the behavior is expected. When there’s no slots (or no cluster nodes), ioredis will reconnect to cluster in order to connect to the new nodes once the cluster has been set up.

You are supposed to pass an array of IPs to new IoRedis.Cluster(…). Is it supposed to automatically pick up a new node when it joins or how do you add the new node?

ioredis is able to discover new node automatically, so you can just provide some of the nodes in the cluster instead of providing all of them.

Any reason why if there are no slots, ioredis automatically disconnect?

The root reason of that is because ioredis doesn’t know where the commands should be sent to when CLUSTER SLOTS returns [] since it relies on CLUSTER SLOTS command to know which nodes are in the cluster.

What if I want to write a script in node to setup the cluster?

That’s a good question. This issue happens basically because Cluster class is designed to work with a cluster that already set. You can use Redis class to send the MEET or any commands to setup the cluster (and since you already know the IPs of the target node, so this way should be pretty straightforward).

0reactions
ccinellicommented, May 15, 2019

The problem seems to be here: https://github.com/luin/ioredis/blob/master/lib/cluster/ConnectionPool.ts#L126 Any reason why if there are no slots, ioredis automatically disconnect? Can this behavior at least be optional ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis cluster node with status DISCONNECTED - FatDBA
Cluster check command is showing details only for three healthy masters and throwing error at the end of the check '[ERR] Not all...
Read more >
Installing Redis Cluster (cluster mode enabled) with auto failover
The cluster-replicas 1 means one slave node for each master. The output of this command will look something like this: >>> Performing hash...
Read more >
postgresql - Patroni : How to handle a replica which has been ...
In this case I think the size of WAL on the primary will keep on growing as it is not being consumed by...
Read more >
Known issues with Storage Replica | Microsoft Learn
This issue occurs when you create a VSS snapshot of the log volume. The underlying cause is a legacy design aspect of VSS,...
Read more >
Scaling with Redis Cluster
Moving hash slots from a node to another does not require stopping any ... a Redis Cluster node automatically persists the cluster configuration...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found