-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NODE-5720): on pre-4.4 sharded servers, the node driver uses error.writeConcern.code
to determine retryability
#4155
base: main
Are you sure you want to change the base?
Conversation
fb7495d
to
dcef868
Compare
test/integration/retryable-writes/retryable_writes.spec.test.ts
Outdated
Show resolved
Hide resolved
test/integration/retryable-writes/retryable_writes.spec.test.ts
Outdated
Show resolved
Hide resolved
WriteConcernError.code
to determine retryability
WriteConcernError.code
to determine retryabilityWriteConcernError.code
to add RetryableWriteLabel
WriteConcernError.code
to add RetryableWriteLabel
WriteConcernError.code
to determine retryability
25a4196
to
231fb80
Compare
WriteConcernError.code
to determine retryabilityWriteConcernError.code
to determine retryability
clear up logic lint fix clean up lint fix 2
370b1a9
to
ad5b150
Compare
src/error.ts
Outdated
@@ -1237,11 +1242,13 @@ export function needsRetryableWriteLabel(error: Error, maxWireVersion: number): | |||
} | |||
|
|||
if (error instanceof MongoWriteConcernError) { | |||
return RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? error.code ?? 0); | |||
return serverType === 'Mongos' && maxWireVersion < 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is right still - the spec says that for <4.4 mongoses, we do check the top level code, we just don't check writeConcernError.code. As written, I think that this will always return false if a writeConcernError
is returned with a top-level retryable error code, when instead we should be hitting the if-statement on line 1250.
Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if
statement in like 1250 checks for error.code
and if the error is a writeConcernError
it will check for writeConcernError.code.
Because of this we wouldn't a <4.4 sharded writeConcernError getting to line 1250.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'm saying that I think it's supposed to reach line 1250 but for a pre-4.4 mongos writeConcernError, we will always return false
here.
if ( | ||
this.configuration.topologyType === 'Sharded' && | ||
lt(this.configuration.version, '4.4.0') | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to check the description, right? we don't want to skip all tests on <4.4 mongoses.
Also - we usually attach a skip reason:
this.currentTest.skipReason = ...
this.skip();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attached the skip reason and moved the server type, server version, and test.description check to all in one place!
WriteConcernError.code
to determine retryabilityerror.writeConcern.code
to determine retryability
4085658
to
a57fb1d
Compare
a57fb1d
to
ac247a7
Compare
Description
On pre-4.4
Mongos
servers, no longer add aRetryableWriteLabel
toWriteConcernError
due to itscode
property.What is changing?
Sync some retryable write spec tests and adhere to spec guidelines.
Is there new documentation needed for these changes?
No.
What is the motivation for this change?
Spec compliance.
Release Highlight
On pre-4.4 sharded servers, the node driver uses the 'writeConcernError.code` field determine retryability
This fix was made to comply with spec guidelines.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript