{
  "runOn": [
    {
      "minServerVersion": "4.0",
      "topology": [
        "replicaset"
      ]
    },
    {
      "minServerVersion": "4.1.8",
      "topology": [
        "sharded"
      ]
    }
  ],
  "database_name": "transaction-tests",
  "collection_name": "test",
  "data": [],
  "tests": [
    {
      "description": "DuplicateKey errors do not contain transient label",
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "documents": [
              {
                "_id": 1
              },
              {
                "_id": 1
              }
            ]
          },
          "result": {
            "errorLabelsOmit": [
              "TransientTransactionError",
              "UnknownTransactionCommitResult"
            ],
            "errorContains": "E11000"
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                },
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "NotMaster errors contain transient label",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "insert"
          ],
          "errorCode": 10107
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "WriteConflict errors contain transient label",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "insert"
          ],
          "errorCode": 112
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "NoSuchTransaction errors contain transient label",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "insert"
          ],
          "errorCode": 251
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "NoSuchTransaction errors on commit contain transient label",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "errorCode": 251
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "add TransientTransactionError label to connection errors, but do not add RetryableWriteError label",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 4
        },
        "data": {
          "failCommands": [
            "insert",
            "find",
            "aggregate",
            "distinct"
          ],
          "closeConnection": true
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "find",
          "object": "collection",
          "arguments": {
            "session": "session0"
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "aggregate",
          "object": "collection",
          "arguments": {
            "pipeline": [
              {
                "$project": {
                  "_id": 1
                }
              }
            ],
            "session": "session0"
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "distinct",
          "object": "collection",
          "arguments": {
            "fieldName": "_id",
            "session": "session0"
          },
          "result": {
            "errorLabelsContain": [
              "TransientTransactionError"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "find": "test",
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false
            },
            "command_name": "find",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "pipeline": [
                {
                  "$project": {
                    "_id": 1
                  }
                }
              ],
              "cursor": {},
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false
            },
            "command_name": "aggregate",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "distinct": "test",
              "key": "_id",
              "lsid": "session0",
              "readConcern": null,
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false
            },
            "command_name": "distinct",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 2
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "closeConnection": true
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to retryable commit errors",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 2
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "errorCode": 11602,
          "errorLabels": [
            "RetryableWriteError"
          ]
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to writeConcernError ShutdownInProgress",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 2
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "writeConcernError": {
            "code": 91,
            "errmsg": "Replication is being shut down",
            "errorLabels": [
              "RetryableWriteError"
            ]
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "do not add RetryableWriteError label to writeConcernError ShutdownInProgress that occurs within transaction",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "insert"
          ],
          "writeConcernError": {
            "code": 91,
            "errmsg": "Replication is being shut down"
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "errorLabelsContain": [],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "TransientTransactionError",
              "UnknownTransactionCommitResult"
            ]
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "writeConcernError": {
            "code": 64,
            "errmsg": "multiple errors reported"
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "writeConcernError": {
            "code": 64,
            "codeName": "WriteConcernFailed",
            "errmsg": "waiting for replication timed out",
            "errInfo": {
              "wtimeout": true
            }
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "omit UnknownTransactionCommitResult label from writeConcernError UnsatisfiableWriteConcern",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "writeConcernError": {
            "code": 100,
            "errmsg": "Not enough data-bearing nodes"
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsOmit": [
              "RetryableWriteError",
              "TransientTransactionError",
              "UnknownTransactionCommitResult"
            ]
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "omit UnknownTransactionCommitResult label from writeConcernError UnknownReplWriteConcern",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "writeConcernError": {
            "code": 79,
            "errmsg": "No write concern mode named 'blah' found in replica set configuration"
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsOmit": [
              "RetryableWriteConcern",
              "TransientTransactionError",
              "UnknownTransactionCommitResult"
            ]
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              }
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "do not add UnknownTransactionCommitResult label to MaxTimeMSExpired inside transactions",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "aggregate"
          ],
          "errorCode": 50
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0"
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "aggregate",
          "object": "collection",
          "arguments": {
            "pipeline": [
              {
                "$project": {
                  "_id": 1
                }
              }
            ],
            "maxTimeMS": 60000,
            "session": "session0"
          },
          "result": {
            "errorLabelsOmit": [
              "RetryableWriteError",
              "UnknownTransactionCommitResult",
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "abortTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "pipeline": [
                {
                  "$project": {
                    "_id": 1
                  }
                }
              ],
              "cursor": {},
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "autocommit": false,
              "maxTimeMS": 60000
            },
            "command_name": "aggregate",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "abortTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "abortTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": []
        }
      }
    },
    {
      "description": "add UnknownTransactionCommitResult label to MaxTimeMSExpired",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "errorCode": 50
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              },
              "maxCommitTimeMS": 60000
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              },
              "maxTimeMS": 60000
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              },
              "maxTimeMS": 60000
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    },
    {
      "description": "add UnknownTransactionCommitResult label to writeConcernError MaxTimeMSExpired",
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 1
        },
        "data": {
          "failCommands": [
            "commitTransaction"
          ],
          "writeConcernError": {
            "code": 50,
            "errmsg": "operation exceeded time limit"
          }
        }
      },
      "operations": [
        {
          "name": "startTransaction",
          "object": "session0",
          "arguments": {
            "options": {
              "writeConcern": {
                "w": "majority"
              },
              "maxCommitTimeMS": 60000
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "session": "session0",
            "document": {
              "_id": 1
            }
          },
          "result": {
            "insertedId": 1
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0",
          "result": {
            "errorLabelsContain": [
              "UnknownTransactionCommitResult"
            ],
            "errorLabelsOmit": [
              "RetryableWriteError",
              "TransientTransactionError"
            ]
          }
        },
        {
          "name": "commitTransaction",
          "object": "session0"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "insert": "test",
              "documents": [
                {
                  "_id": 1
                }
              ],
              "ordered": true,
              "readConcern": null,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": true,
              "autocommit": false,
              "writeConcern": null
            },
            "command_name": "insert",
            "database_name": "transaction-tests"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority"
              },
              "maxTimeMS": 60000
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        },
        {
          "command_started_event": {
            "command": {
              "commitTransaction": 1,
              "lsid": "session0",
              "txnNumber": {
                "$numberLong": "1"
              },
              "startTransaction": null,
              "autocommit": false,
              "writeConcern": {
                "w": "majority",
                "wtimeout": 10000
              },
              "maxTimeMS": 60000
            },
            "command_name": "commitTransaction",
            "database_name": "admin"
          }
        }
      ],
      "outcome": {
        "collection": {
          "data": [
            {
              "_id": 1
            }
          ]
        }
      }
    }
  ]
}
