Skip to content

Commit 72fd804

Browse files
committed
fix(cluster): set retryDelayOnFailover from 2000ms to 200ms
1 parent 0dcb768 commit 72fd804

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

API.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ Creates a Redis Cluster instance
216216
| options | <code>Object</code> | | |
217217
| [options.enableOfflineQueue] | <code>boolean</code> | <code>true</code> | See Redis class |
218218
| [options.lazyConnect] | <code>boolean</code> | <code>false</code> | See Redis class |
219-
| [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". |
219+
| [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". |
220220
| [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. |
221221
| [options.clusterRetryStrategy] | <code>function</code> | | See "Quick Start" section |
222-
| [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), |
223-
| [options.retryDelayOnClusterDown] | <code>number</code> | <code>1000</code> | When a CLUSTERDOWN error is received, client will retry if `retryDelayOnClusterDown` is valid delay time. |
222+
| [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), |
223+
| [options.retryDelayOnClusterDown] | <code>number</code> | <code>100</code> | When a CLUSTERDOWN error is received, client will retry if `retryDelayOnClusterDown` is valid delay time. |
224224

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

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

249249
<a name="Commander+getBuiltinCommands"></a>
250250
### cluster.getBuiltinCommands() ⇒ <code>Array.&lt;string&gt;</code>

lib/cluster/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ var ConnectionPool = require('./connection_pool');
2727
* @param {number} [options.maxRedirections=16] - When a MOVED or ASK error is received, client will redirect the
2828
* command to another node. This option limits the max redirections allowed to send a command.
2929
* @param {function} [options.clusterRetryStrategy] - See "Quick Start" section
30-
* @param {number} [options.retryDelayOnFailover=2000] - When an error is received when sending a command(e.g.
30+
* @param {number} [options.retryDelayOnFailover=100] - When an error is received when sending a command(e.g.
3131
* "Connection is closed." when the target Redis node is down),
32-
* @param {number} [options.retryDelayOnClusterDown=1000] - When a CLUSTERDOWN error is received, client will retry
32+
* @param {number} [options.retryDelayOnClusterDown=100] - When a CLUSTERDOWN error is received, client will retry
3333
* if `retryDelayOnClusterDown` is valid delay time.
3434
* @extends [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter)
3535
* @extends Commander
@@ -103,8 +103,8 @@ function Cluster(startupNodes, options) {
103103
*/
104104
Cluster.defaultOptions = {
105105
maxRedirections: 16,
106-
retryDelayOnFailover: 2000,
107-
retryDelayOnClusterDown: 1000,
106+
retryDelayOnFailover: 100,
107+
retryDelayOnClusterDown: 100,
108108
scaleReads: 'masters',
109109
enableOfflineQueue: true,
110110
clusterRetryStrategy: function (times) {

test/functional/cluster.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,22 @@ describe('cluster', function () {
339339
});
340340

341341
it('should be able to redirect a command to a unknown node', function (done) {
342-
var slotTable = [
343-
[0, 16383, ['127.0.0.1', 30001]]
344-
];
345342
var node1 = new MockServer(30001, function (argv) {
346343
if (argv[0] === 'cluster' && argv[1] === 'slots') {
347-
return slotTable;
344+
return [
345+
[0, 16383, ['127.0.0.1', 30001]]
346+
];
348347
}
349348
if (argv[0] === 'get' && argv[1] === 'foo') {
350349
return new Error('MOVED ' + utils.calcSlot('foo') + ' 127.0.0.1:30002');
351350
}
352351
});
353352
var node2 = new MockServer(30002, function (argv) {
354353
if (argv[0] === 'cluster' && argv[1] === 'slots') {
355-
return slotTable;
354+
return [
355+
[0, 16381, ['127.0.0.1', 30001]],
356+
[16382, 16383, ['127.0.0.1', 30002]]
357+
];
356358
}
357359
if (argv[0] === 'get' && argv[1] === 'foo') {
358360
return 'bar';

0 commit comments

Comments
 (0)