Skip to content

Commit

Permalink
fix(Cluster): issues when setting enableOfflineQueue to false (#649)
Browse files Browse the repository at this point in the history
Offline queue should be enabled on the internal
cluster nodes so that we don't need to wait for the
`ready` event before sending commands to the node.
  • Loading branch information
luin authored Jun 30, 2018
1 parent 47654cd commit cfe4258
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/cluster/connection_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ConnectionPool.prototype.findOrCreate = function (node, readOnly) {
redis = this.nodes.all[node.key];
if (redis.options.readOnly !== readOnly) {
redis.options.readOnly = readOnly;
debug('Change role of %s to %s', node.key, readOnly ? 'slave' : 'master')
debug('Change role of %s to %s', node.key, readOnly ? 'slave' : 'master');
redis[readOnly ? 'readonly' : 'readwrite']().catch(_.noop);
if (readOnly) {
delete this.nodes.master[node.key];
Expand All @@ -59,7 +59,14 @@ ConnectionPool.prototype.findOrCreate = function (node, readOnly) {
} else {
debug('Connecting to %s as %s', node.key, readOnly ? 'slave' : 'master');
redis = new Redis(_.defaults({
// Never try to reconnect when a node is lose,
// instead, waiting for a `MOVED` error and
// fetch the slots again.
retryStrategy: null,
// Offline queue should be enabled so that
// we don't need to wait for the `ready` event
// before sending commands to the node.
enableOfflineQueue: true,
readOnly: readOnly
}, node, this.redisOptions, { lazyConnect: true }));
this.nodes.all[node.key] = redis;
Expand Down

0 comments on commit cfe4258

Please sign in to comment.