Repository navigation
Transient failure retries - #574
Conversation
|
Some tests failing on Linux for NodeJS 4. Error suggests issue with machine state than code:
Is there some way to retrigger the test without submitting a dummy change? |
|
I made a dummy PR (#575) with the same changes which triggered a re-run and tests pass now. |
| @@ -0,0 +1,17 @@ | |||
| class TransientErrorLookup { | |||
There was a problem hiding this comment.
Why is the isTransientError() function within a class?
Why is it in a separate JS file?
There was a problem hiding this comment.
This makes it easier and cleaner to stub it out in the tests. Add a comment to clarify that.
| // - https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs#L115 | ||
| const transientErrors = [4060, 10928, 10929, 40197, 40501, 40613]; | ||
|
|
||
| for (let j = 0; j < transientErrors.length; j++) { |
There was a problem hiding this comment.
Why not use Array.indexOf()? It's available in the current Node 4 version (4.8.3).
| const isLoginErrorTransient = this.transientErrorLookup.isTransientError(token.number); | ||
| if (isLoginErrorTransient && this.curTransientRetryCount !== this.config.options.maxRetriesOnTransientErrors) { | ||
| this.debug.log('Initiating retry on transient error = ', token.number); | ||
| return this.transitionTo(this.STATE.TRANSIENT_FAILURE_RETRY); |
There was a problem hiding this comment.
The "return" statements with a value are an artefact of the CoffeeScript to JavaScript conversion and should not be used where it makes no sense.
There was a problem hiding this comment.
Done.
Added a clean-up item to remove these across the board - #576
| } | ||
| } else { | ||
| const isLoginErrorTransient = this.transientErrorLookup.isTransientError(token.number); | ||
| if (isLoginErrorTransient && this.curTransientRetryCount !== this.config.options.maxRetriesOnTransientErrors) { |
There was a problem hiding this comment.
Better use < than !== for comparing a retry count.
| const port = this.routingData ? this.routingData.port : this.config.options.port; | ||
| this.debug.log('Retry after transient failure connecting to ' + server + ':' + port); | ||
|
|
||
| return this.dispatchEvent('retry'); |
There was a problem hiding this comment.
Why not just call createRetryTimer() here? dispatchEvent() is executed synchronously and there is no transition to another state.
There was a problem hiding this comment.
I think that'd make it harder to follow the logic. Now it's easy to see what's happening by looking at code under TRANSIENT_FAILURE_RETRY and back track from there.
| @@ -0,0 +1,20 @@ | |||
| const TransientErrorLookup = require('../../src/transient-error-lookup').TransientErrorLookup; | |||
|
|
|||
There was a problem hiding this comment.
This test case seems very superfluous to me for such a simple function as isTransientError(). Otherwise you better write a test case for the test case in this case... :)
There was a problem hiding this comment.
Makes it even more silly now that I changed the code to indexOf :-)
This is just an assertion to make sure any additions or deletion from list of transient errors is intentional.
There was a problem hiding this comment.
btw, this test actually caught a bug when I switched to Array.indexOf per your suggestion. I had return transientErrors.indexOf(error) === -1; where I should have return transientErrors.indexOf(error) !== -1; and this test failed.
| test.expect(config.options.maxRetriesOnTransientErrors + 1); | ||
|
|
||
| this.sinon.stub(TransientErrorLookup.prototype, 'isTransientError', () => { | ||
| return true; |
There was a problem hiding this comment.
Why not test for the error code for "invalid password" here?
| const isLoginErrorTransient = this.transientErrorLookup.isTransientError(token.number); | ||
| if (isLoginErrorTransient && this.curTransientRetryCount !== this.config.options.maxRetriesOnTransientErrors) { | ||
| this.debug.log('Initiating retry on transient error = ', token.number); | ||
| return this.transitionTo(this.STATE.TRANSIENT_FAILURE_RETRY); |
There was a problem hiding this comment.
Done.
Added a clean-up item to remove these across the board - #576
| const port = this.routingData ? this.routingData.port : this.config.options.port; | ||
| this.debug.log('Retry after transient failure connecting to ' + server + ':' + port); | ||
|
|
||
| return this.dispatchEvent('retry'); |
There was a problem hiding this comment.
I think that'd make it harder to follow the logic. Now it's easy to see what's happening by looking at code under TRANSIENT_FAILURE_RETRY and back track from there.
| @@ -0,0 +1,17 @@ | |||
| class TransientErrorLookup { | |||
There was a problem hiding this comment.
This makes it easier and cleaner to stub it out in the tests. Add a comment to clarify that.
| // - https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs#L115 | ||
| const transientErrors = [4060, 10928, 10929, 40197, 40501, 40613]; | ||
|
|
||
| for (let j = 0; j < transientErrors.length; j++) { |
| test.expect(config.options.maxRetriesOnTransientErrors + 1); | ||
|
|
||
| this.sinon.stub(TransientErrorLookup.prototype, 'isTransientError', () => { | ||
| return true; |
| @@ -0,0 +1,20 @@ | |||
| const TransientErrorLookup = require('../../src/transient-error-lookup').TransientErrorLookup; | |||
|
|
|||
There was a problem hiding this comment.
Makes it even more silly now that I changed the code to indexOf :-)
This is just an assertion to make sure any additions or deletion from list of transient errors is intentional.
|
@chdh Addressed/responded to your comments. If you don't have more comments I'll commit this. Thanks! |
@arthurschreiber @chdh This adds retries for transient failures that all Microsoft drivers do to improve reliability. This could address some of the connection failures issues that have been reported over time.