@@ -353,7 +353,7 @@ and sharded clusters.
353
353
retryWrites=false to your connection string.
354
354
355
355
and the error code is 20.
356
-
356
+
357
357
**Note **: Drivers that rely on ``serverStatus `` to determine the storage engine
358
358
in use MAY skip this test for sharded clusters, since ``mongos `` does not report
359
359
this information in its ``serverStatus `` response.
@@ -395,10 +395,72 @@ and sharded clusters.
395
395
396
396
9. Disable the failpoint.
397
397
398
+ #. Test that drivers return the original error after encountering a
399
+ WriteConcernError with a RetryableWriteError label. This test MUST
400
+
401
+ 1. be implemented by any driver that implements the Command Monitoring
402
+ specification,
403
+
404
+ 2. only run against replica sets as mongos does not propagate the
405
+ NoWritesPerformed label to the drivers.
406
+
407
+ Additionally, this test requires drivers to set a fail point after an
408
+ ``insertOne `` operation but before the subsequent retry. Drivers that are
409
+ unable to set a failCommand after the CommandSucceededEvent SHOULD use
410
+ mocking or write a unit test to cover the same sequence of events.
411
+
412
+
413
+ 1. Create a client with ``retryWrites=true ``.
414
+
415
+ 2. Configure a fail point with error code ``91 `` (ShutdownInProgress)::
416
+
417
+ db.adminCommand({
418
+ configureFailPoint: "failCommand",
419
+ mode: {times: 1},
420
+ data: {
421
+ writeConcernError: {
422
+ code: 91,
423
+ errorLabels: ["RetryableWriteError"],
424
+ },
425
+ failCommands: ["insert"],
426
+ },
427
+ });
428
+
429
+ 3. Via the command monitoring CommandSucceededEvent, configure a fail point
430
+ with error code ``10107 `` (NotWritablePrimary) and a NoWritesPerformed
431
+ label::
432
+
433
+ db.adminCommand({
434
+ configureFailPoint: "failCommand",
435
+ mode: {times: 1},
436
+ data: {
437
+ errorCode: 10107,
438
+ errorLabels: ["RetryableWriteError", "NoWritesPerformed"],
439
+ failCommands: ["insert"],
440
+ },
441
+ });
442
+
443
+ Drivers SHOULD only configure the ``10107 `` fail point command if the the
444
+ succeeded event is for the ``91 `` error configured in step 2.
445
+
446
+ 4. Attempt an ``insertOne `` operation on any record for any database and
447
+ collection. For the resulting error, assert that the associated error code
448
+ is ``91 ``.
449
+
450
+ 5. Disable the fail point::
451
+
452
+ db.adminCommand({
453
+ configureFailPoint: "failCommand",
454
+ mode: "off",
455
+ })
398
456
399
457
Changelog
400
458
=========
401
459
460
+ :2022-08-30: Add prose test verifying correct error handling for errors with
461
+ the NoWritesPerformed label, which is to return the original
462
+ error.
463
+
402
464
:2022-04-22: Clarifications to ``serverless `` and ``useMultipleMongoses ``.
403
465
404
466
:2021-08-27: Add ``serverless `` to ``runOn ``. Clarify behavior of
0 commit comments