...

Text file src/go.mongodb.org/mongo-driver/testdata/retryable-writes/legacy/insertMany-errorLabels.yml

Documentation: go.mongodb.org/mongo-driver/testdata/retryable-writes/legacy

     1runOn:
     2    - minServerVersion: "4.3.1"
     3      topology: ["replicaset", "sharded", "load-balanced"]
     4
     5data:
     6    - { _id: 1, x: 11 }
     7
     8tests:
     9    - description: "InsertMany succeeds with RetryableWriteError from server"
    10      failPoint:
    11          configureFailPoint: failCommand
    12          mode: { times: 1 }
    13          data:
    14              failCommands: ["insert"]
    15              errorCode: 112 # WriteConflict, not a retryable error code
    16              errorLabels: ["RetryableWriteError"] # Override server behavior: send RetryableWriteError label with non-retryable error code
    17      operation:
    18          name: "insertMany"
    19          arguments:
    20              documents:
    21                  - { _id: 2, x: 22 }
    22                  - { _id: 3, x: 33 }
    23              options: { ordered: true }
    24      outcome: # Driver retries operation and it succeeds
    25          result:
    26              insertedIds: { 0: 2, 1: 3 }
    27          collection:
    28              data:
    29                  - { _id: 1, x: 11 }
    30                  - { _id: 2, x: 22 }
    31                  - { _id: 3, x: 33 }
    32
    33    - description: "InsertMany fails if server does not return RetryableWriteError"
    34      failPoint:
    35          configureFailPoint: failCommand
    36          mode: { times: 1 }
    37          data:
    38              failCommands: ["insert"]
    39              errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code
    40              errorLabels: []  # Override server behavior: do not send RetryableWriteError label with retryable code
    41      operation:
    42          name: "insertMany"
    43          arguments:
    44              documents:
    45                  - { _id: 2, x: 22 }
    46                  - { _id: 3, x: 33 }
    47              options: { ordered: true }
    48      outcome:
    49          error: true # Driver does not retry operation because there was no RetryableWriteError label on response
    50          result:
    51              errorLabelsOmit: ["RetryableWriteError"]
    52          collection:
    53              data:
    54                  - { _id: 1, x: 11 }

View as plain text