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

Message event fired multiple times (usually random count) after cluster restart #803

Closed
nolimitdev opened this issue Feb 27, 2019 · 4 comments

Comments

@nolimitdev
Copy link

nolimitdev commented Feb 27, 2019

Hello, when I was reporting bug related to unhanded error when used subscribe in cluster I found another bug. When you are subscribed in cluster and cluster is restarted then the same message event is fired multiple times (count is always another number for each test - e.g. from 2 times to several tens times). Number of duplicated messages seems to be depending on how long is cluster down. When I only restart cluster (so it is down for a while) then the same message is fired e.g. 2 times. When I shutdown cluster for a minute then the same message is fired several tens times. This issue is related only to cluster version (non-cluster works OK). Tested in latest version 4.6.3 on both Windows and Linux (Debian) - result is the same - see below.


Start redis cluster, then run node cluster.js and few seconds later shutdown all nodes and start it again...

// file cluster.js
var ioredis = require('ioredis');
var nodes = [{host: 'localhost', port: 7001}, {host: 'localhost', port: 7002}];
var redis = new ioredis.Cluster(nodes);

redis.on('error', function(error) {
    console.log('Redis cluster error:', error.message);
});

redis.on('ready', function() {
    console.log('Redis cluster is ready');
});

redis.on('node error', function(error, address) {
    console.log('Redis cluster node ' + address + ' error:', error.message);
});

redis.subscribe('item', function(error, count) {
    if (error)
        console.log('Subscribe error:', error.message);
    else
        console.log('Subscribe count:', count);
});

redis.on('message', function(channel, message) {
    console.log(new Date(), 'Redis message: ', channel, message);
});

Result:

Redis cluster is ready
Subscribe count: 1
// I have published one message before restart - it is OK
2019-02-27T14:12:29.768Z 'Redis message: ' 'item' '123'
Redis cluster node 127.0.0.1:7002 error: timeout
Redis cluster node 127.0.0.1:7001 error: timeout
Redis cluster error: Failed to refresh slots cache.
Redis cluster node 127.0.0.1:7002 error: timeout
Redis cluster node 127.0.0.1:7001 error: timeout
Redis cluster error: Failed to refresh slots cache.
Redis cluster is ready
// I have published onother one message after restart - it is multiplied (see time - almost identical)
2019-02-27T14:12:53.600Z 'Redis message: ' 'item' '123'
2019-02-27T14:12:53.601Z 'Redis message: ' 'item' '123'
2019-02-27T14:12:53.602Z 'Redis message: ' 'item' '123'
2019-02-27T14:12:53.603Z 'Redis message: ' 'item' '123'
2019-02-27T14:12:53.603Z 'Redis message: ' 'item' '123'
2019-02-27T14:12:53.603Z 'Redis message: ' 'item' '123'

@stale
Copy link

stale bot commented Mar 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot added the wontfix label Mar 29, 2019
@stale stale bot closed this as completed Apr 5, 2019
@jignesh248
Copy link

@nolimitdev were you able to figure out how to avoid this situation? I am in similar situation, and I feel I am doing something wrong on my end.

@nolimitdev
Copy link
Author

nolimitdev commented Apr 24, 2019 via email

@nolimitdev
Copy link
Author

nolimitdev commented Jun 11, 2020

Wow, I have updated from v4.6.3 to latest v4.17.3 and issue is away. So it seems to be safe to use cluster via ioredis for pub/sub now. @jignesh248 can you please confirm it too?

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

No branches or pull requests

2 participants