Skip to content

Commit

Permalink
fix(cluster): set retryDelayOnFailover from 2000ms to 200ms
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Feb 8, 2016
1 parent 0dcb768 commit 72fd804
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ Creates a Redis Cluster instance
| options | <code>Object</code> | | |
| [options.enableOfflineQueue] | <code>boolean</code> | <code>true</code> | See Redis class |
| [options.lazyConnect] | <code>boolean</code> | <code>false</code> | See Redis class |
| [options.scaleReads] | <code>string</code> | <code>&quot;\&quot;masters\&quot;&quot;</code> | Scale reads to the node with the specified role. Available values are "masters", "slaves" and "all". |
| [options.scaleReads] | <code>string</code> | <code>&quot;masters&quot;</code> | Scale reads to the node with the specified role. Available values are "masters", "slaves" and "all". |
| [options.maxRedirections] | <code>number</code> | <code>16</code> | When a MOVED or ASK error is received, client will redirect the command to another node. This option limits the max redirections allowed to send a command. |
| [options.clusterRetryStrategy] | <code>function</code> | | See "Quick Start" section |
| [options.retryDelayOnFailover] | <code>number</code> | <code>2000</code> | When an error is received when sending a command(e.g. "Connection is closed." when the target Redis node is down), |
| [options.retryDelayOnClusterDown] | <code>number</code> | <code>1000</code> | When a CLUSTERDOWN error is received, client will retry if `retryDelayOnClusterDown` is valid delay time. |
| [options.retryDelayOnFailover] | <code>number</code> | <code>100</code> | When an error is received when sending a command(e.g. "Connection is closed." when the target Redis node is down), |
| [options.retryDelayOnClusterDown] | <code>number</code> | <code>100</code> | When a CLUSTERDOWN error is received, client will retry if `retryDelayOnClusterDown` is valid delay time. |

<a name="Cluster+connect"></a>
### cluster.connect() ⇒ <code>Promise</code>
Expand All @@ -244,7 +244,7 @@ Get nodes with the specified role

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [role] | <code>string</code> | <code>&quot;\&quot;all\&quot;&quot;</code> | role, "masters", "slaves" or "all" |
| [role] | <code>string</code> | <code>&quot;all&quot;</code> | role, "masters", "slaves" or "all" |

<a name="Commander+getBuiltinCommands"></a>
### cluster.getBuiltinCommands() ⇒ <code>Array.&lt;string&gt;</code>
Expand Down
8 changes: 4 additions & 4 deletions lib/cluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ var ConnectionPool = require('./connection_pool');
* @param {number} [options.maxRedirections=16] - When a MOVED or ASK error is received, client will redirect the
* command to another node. This option limits the max redirections allowed to send a command.
* @param {function} [options.clusterRetryStrategy] - See "Quick Start" section
* @param {number} [options.retryDelayOnFailover=2000] - When an error is received when sending a command(e.g.
* @param {number} [options.retryDelayOnFailover=100] - When an error is received when sending a command(e.g.
* "Connection is closed." when the target Redis node is down),
* @param {number} [options.retryDelayOnClusterDown=1000] - When a CLUSTERDOWN error is received, client will retry
* @param {number} [options.retryDelayOnClusterDown=100] - When a CLUSTERDOWN error is received, client will retry
* if `retryDelayOnClusterDown` is valid delay time.
* @extends [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)
* @extends Commander
Expand Down Expand Up @@ -103,8 +103,8 @@ function Cluster(startupNodes, options) {
*/
Cluster.defaultOptions = {
maxRedirections: 16,
retryDelayOnFailover: 2000,
retryDelayOnClusterDown: 1000,
retryDelayOnFailover: 100,
retryDelayOnClusterDown: 100,
scaleReads: 'masters',
enableOfflineQueue: true,
clusterRetryStrategy: function (times) {
Expand Down
12 changes: 7 additions & 5 deletions test/functional/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,20 +339,22 @@ describe('cluster', function () {
});

it('should be able to redirect a command to a unknown node', function (done) {
var slotTable = [
[0, 16383, ['127.0.0.1', 30001]]
];
var node1 = new MockServer(30001, function (argv) {
if (argv[0] === 'cluster' && argv[1] === 'slots') {
return slotTable;
return [
[0, 16383, ['127.0.0.1', 30001]]
];
}
if (argv[0] === 'get' && argv[1] === 'foo') {
return new Error('MOVED ' + utils.calcSlot('foo') + ' 127.0.0.1:30002');
}
});
var node2 = new MockServer(30002, function (argv) {
if (argv[0] === 'cluster' && argv[1] === 'slots') {
return slotTable;
return [
[0, 16381, ['127.0.0.1', 30001]],
[16382, 16383, ['127.0.0.1', 30002]]
];
}
if (argv[0] === 'get' && argv[1] === 'foo') {
return 'bar';
Expand Down

0 comments on commit 72fd804

Please sign in to comment.