Skip to content

Commit 05d54a3

Browse files
refactor(NODE-6758): rename WriteConcernError enum key to WriteConcernTimeout (#4483)
1 parent 40d0e87 commit 05d54a3

File tree

8 files changed

+16
-23
lines changed

8 files changed

+16
-23
lines changed

src/bulk/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class BulkWriteResult {
285285
if (i === 0) errmsg = errmsg + ' and ';
286286
}
287287

288-
return new WriteConcernError({ errmsg, code: MONGODB_ERROR_CODES.WriteConcernFailed });
288+
return new WriteConcernError({ errmsg, code: MONGODB_ERROR_CODES.WriteConcernTimeout });
289289
}
290290
}
291291

src/error.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export const MONGODB_ERROR_CODES = Object.freeze({
5656
FailedToSatisfyReadPreference: 133,
5757
CursorNotFound: 43,
5858
LegacyNotPrimary: 10058,
59-
WriteConcernFailed: 64,
59+
// WriteConcernTimeout is WriteConcernFailed on pre-8.1 servers
60+
WriteConcernTimeout: 64,
6061
NamespaceNotFound: 26,
6162
IllegalOperation: 20,
6263
MaxTimeMSExpired: 50,

test/spec/retryable-writes/unified/insertOne-serverErrors.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@
739739
]
740740
},
741741
{
742-
"description": "InsertOne fails after WriteConcernError WriteConcernFailed",
742+
"description": "InsertOne fails after WriteConcernError WriteConcernTimeout",
743743
"operations": [
744744
{
745745
"name": "failPoint",
@@ -757,7 +757,6 @@
757757
],
758758
"writeConcernError": {
759759
"code": 64,
760-
"codeName": "WriteConcernFailed",
761760
"errmsg": "waiting for replication timed out",
762761
"errInfo": {
763762
"wtimeout": true

test/spec/retryable-writes/unified/insertOne-serverErrors.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ tests:
339339
- { _id: 2, x: 22 }
340340
- { _id: 3, x: 33 } # The write was still applied.
341341
-
342-
description: 'InsertOne fails after WriteConcernError WriteConcernFailed'
342+
description: 'InsertOne fails after WriteConcernError WriteConcernTimeout'
343343
operations:
344344
-
345345
name: failPoint
@@ -353,7 +353,6 @@ tests:
353353
failCommands: [ insert ]
354354
writeConcernError:
355355
code: 64
356-
codeName: WriteConcernFailed
357356
errmsg: 'waiting for replication timed out'
358357
errInfo:
359358
wtimeout: true

test/spec/transactions-convenient-api/unified/commit-writeconcernerror.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
],
5757
"tests": [
5858
{
59-
"description": "commitTransaction is retried after WriteConcernFailed timeout error",
59+
"description": "commitTransaction is retried after WriteConcernTimeout timeout error",
6060
"operations": [
6161
{
6262
"name": "failPoint",
@@ -74,7 +74,6 @@
7474
],
7575
"writeConcernError": {
7676
"code": 64,
77-
"codeName": "WriteConcernFailed",
7877
"errmsg": "waiting for replication timed out",
7978
"errInfo": {
8079
"wtimeout": true
@@ -236,7 +235,7 @@
236235
]
237236
},
238237
{
239-
"description": "commitTransaction is retried after WriteConcernFailed non-timeout error",
238+
"description": "commitTransaction is retried after WriteConcernTimeout non-timeout error",
240239
"operations": [
241240
{
242241
"name": "failPoint",
@@ -254,7 +253,6 @@
254253
],
255254
"writeConcernError": {
256255
"code": 64,
257-
"codeName": "WriteConcernFailed",
258256
"errmsg": "multiple errors reported"
259257
}
260258
}

test/spec/transactions-convenient-api/unified/commit-writeconcernerror.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ initialData:
3232

3333
tests:
3434
-
35-
description: commitTransaction is retried after WriteConcernFailed timeout error
35+
description: commitTransaction is retried after WriteConcernTimeout timeout error
3636
operations:
3737
- name: failPoint
3838
object: testRunner
@@ -47,7 +47,6 @@ tests:
4747
# with writeConcernError (see: SERVER-39292)
4848
writeConcernError:
4949
code: 64
50-
codeName: WriteConcernFailed
5150
errmsg: "waiting for replication timed out"
5251
errInfo: { wtimeout: true }
5352
- &operation
@@ -126,10 +125,10 @@ tests:
126125
- { _id: 1 }
127126
-
128127
# This test configures the fail point to return an error with the
129-
# WriteConcernFailed code but without errInfo that would identify it as a
128+
# WriteConcernTimeout code but without errInfo that would identify it as a
130129
# wtimeout error. This tests that drivers do not assume that all
131-
# WriteConcernFailed errors are due to a replication timeout.
132-
description: commitTransaction is retried after WriteConcernFailed non-timeout error
130+
# WriteConcernTimeout errors are due to a replication timeout.
131+
description: commitTransaction is retried after WriteConcernTimeout non-timeout error
133132
operations:
134133
- name: failPoint
135134
object: testRunner
@@ -144,7 +143,6 @@ tests:
144143
# with writeConcernError (see: SERVER-39292)
145144
writeConcernError:
146145
code: 64
147-
codeName: WriteConcernFailed
148146
errmsg: "multiple errors reported"
149147
- *operation
150148
expectEvents: *expectEvents_with_retries

test/spec/transactions/unified/error-labels.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@
11761176
]
11771177
},
11781178
{
1179-
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed",
1179+
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernTimeout",
11801180
"operations": [
11811181
{
11821182
"object": "testRunner",
@@ -1338,7 +1338,7 @@
13381338
]
13391339
},
13401340
{
1341-
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout",
1341+
"description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernTimeout with wtimeout",
13421342
"operations": [
13431343
{
13441344
"object": "testRunner",
@@ -1356,7 +1356,6 @@
13561356
],
13571357
"writeConcernError": {
13581358
"code": 64,
1359-
"codeName": "WriteConcernFailed",
13601359
"errmsg": "waiting for replication timed out",
13611360
"errInfo": {
13621361
"wtimeout": true

test/spec/transactions/unified/error-labels.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ tests:
688688
databaseName: *database_name
689689
documents: []
690690
-
691-
description: 'add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed'
691+
description: 'add UnknownTransactionCommitResult label to writeConcernError WriteConcernTimeout'
692692
operations:
693693
-
694694
object: testRunner
@@ -702,7 +702,7 @@ tests:
702702
failCommands:
703703
- commitTransaction
704704
writeConcernError:
705-
code: 64 # WriteConcernFailed without wtimeout
705+
code: 64 # WriteConcernTimeout without wtimeout
706706
errmsg: 'multiple errors reported'
707707
-
708708
object: *session0
@@ -782,7 +782,7 @@ tests:
782782
documents:
783783
- { _id: 1 }
784784
-
785-
description: 'add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout'
785+
description: 'add UnknownTransactionCommitResult label to writeConcernError WriteConcernTimeout with wtimeout'
786786
operations:
787787
-
788788
object: testRunner
@@ -797,7 +797,6 @@ tests:
797797
- commitTransaction
798798
writeConcernError:
799799
code: 64
800-
codeName: WriteConcernFailed
801800
errmsg: 'waiting for replication timed out'
802801
errInfo:
803802
wtimeout: true

0 commit comments

Comments
 (0)