{ "description": "write-concern", "schemaVersion": "1.9", "runOnRequirements": [ { "minServerVersion": "4.0", "topologies": [ "replicaset" ] }, { "minServerVersion": "4.1.8", "topologies": [ "sharded", "load-balanced" ] } ], "createEntities": [ { "client": { "id": "client0", "useMultipleMongoses": false, "observeEvents": [ "commandStartedEvent" ] } }, { "database": { "id": "database0", "client": "client0", "databaseName": "transaction-tests" } }, { "collection": { "id": "collection0", "database": "database0", "collectionName": "test" } }, { "collection": { "id": "collection_w0", "database": "database0", "collectionName": "test", "collectionOptions": { "writeConcern": { "w": 0 } } } }, { "session": { "id": "session0", "client": "client0" } } ], "initialData": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 } ] } ], "tests": [ { "description": "commit with majority", "operations": [ { "object": "session0", "name": "startTransaction", "arguments": { "writeConcern": { "w": "majority" } } }, { "object": "collection0", "name": "insertOne", "arguments": { "session": "session0", "document": { "_id": 1 } }, "expectResult": { "$$unsetOrMatches": { "insertedId": { "$$unsetOrMatches": 1 } } } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "w": "majority" } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 }, { "_id": 1 } ] } ] }, { "description": "commit with default", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection0", "name": "insertOne", "arguments": { "session": "session0", "document": { "_id": 1 } }, "expectResult": { "$$unsetOrMatches": { "insertedId": { "$$unsetOrMatches": 1 } } } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 }, { "_id": 1 } ] } ] }, { "description": "abort with majority", "operations": [ { "object": "session0", "name": "startTransaction", "arguments": { "writeConcern": { "w": "majority" } } }, { "object": "collection0", "name": "insertOne", "arguments": { "session": "session0", "document": { "_id": 1 } }, "expectResult": { "$$unsetOrMatches": { "insertedId": { "$$unsetOrMatches": 1 } } } }, { "object": "session0", "name": "abortTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "abortTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "w": "majority" } }, "commandName": "abortTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 } ] } ] }, { "description": "abort with default", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection0", "name": "insertOne", "arguments": { "session": "session0", "document": { "_id": 1 } }, "expectResult": { "$$unsetOrMatches": { "insertedId": { "$$unsetOrMatches": 1 } } } }, { "object": "session0", "name": "abortTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "abortTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "abortTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 } ] } ] }, { "description": "start with unacknowledged write concern", "operations": [ { "object": "session0", "name": "startTransaction", "arguments": { "writeConcern": { "w": 0 } }, "expectError": { "isClientError": true, "errorContains": "transactions do not support unacknowledged write concern" } } ] }, { "description": "start with implicit unacknowledged write concern", "operations": [ { "object": "testRunner", "name": "createEntities", "arguments": { "entities": [ { "client": { "id": "client1", "useMultipleMongoses": false, "uriOptions": { "w": 0 } } }, { "session": { "id": "session1", "client": "client1" } } ] } }, { "object": "session1", "name": "startTransaction", "expectError": { "isClientError": true, "errorContains": "transactions do not support unacknowledged write concern" } } ] }, { "description": "unacknowledged write concern coll insertOne", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "insertOne", "arguments": { "session": "session0", "document": { "_id": 1 } }, "expectResult": { "$$unsetOrMatches": { "insertedId": { "$$unsetOrMatches": 1 } } } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 }, { "_id": 1 } ] } ] }, { "description": "unacknowledged write concern coll insertMany", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "insertMany", "arguments": { "session": "session0", "documents": [ { "_id": 1 }, { "_id": 2 } ] }, "expectResult": { "$$unsetOrMatches": { "insertedIds": { "$$unsetOrMatches": { "0": 1, "1": 2 } } } } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 }, { "_id": 2 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 }, { "_id": 1 }, { "_id": 2 } ] } ] }, { "description": "unacknowledged write concern coll bulkWrite", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "bulkWrite", "arguments": { "session": "session0", "requests": [ { "insertOne": { "document": { "_id": 1 } } } ] }, "expectResult": { "deletedCount": 0, "insertedCount": 1, "insertedIds": { "$$unsetOrMatches": { "0": 1 } }, "matchedCount": 0, "modifiedCount": 0, "upsertedCount": 0, "upsertedIds": {} } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "insert": "test", "documents": [ { "_id": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "insert", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0 }, { "_id": 1 } ] } ] }, { "description": "unacknowledged write concern coll deleteOne", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "deleteOne", "arguments": { "session": "session0", "filter": { "_id": 0 } }, "expectResult": { "deletedCount": 1 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "delete": "test", "deletes": [ { "q": { "_id": 0 }, "limit": 1 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "delete", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [] } ] }, { "description": "unacknowledged write concern coll deleteMany", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "deleteMany", "arguments": { "session": "session0", "filter": { "_id": 0 } }, "expectResult": { "deletedCount": 1 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "delete": "test", "deletes": [ { "q": { "_id": 0 }, "limit": 0 } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "delete", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [] } ] }, { "description": "unacknowledged write concern coll updateOne", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "updateOne", "arguments": { "session": "session0", "filter": { "_id": 0 }, "update": { "$inc": { "x": 1 } }, "upsert": true }, "expectResult": { "matchedCount": 1, "modifiedCount": 1, "upsertedCount": 0 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "update": "test", "updates": [ { "q": { "_id": 0 }, "u": { "$inc": { "x": 1 } }, "upsert": true, "multi": { "$$unsetOrMatches": false } } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "update", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0, "x": 1 } ] } ] }, { "description": "unacknowledged write concern coll updateMany", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "updateMany", "arguments": { "session": "session0", "filter": { "_id": 0 }, "update": { "$inc": { "x": 1 } }, "upsert": true }, "expectResult": { "matchedCount": 1, "modifiedCount": 1, "upsertedCount": 0 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "update": "test", "updates": [ { "q": { "_id": 0 }, "u": { "$inc": { "x": 1 } }, "multi": true, "upsert": true } ], "ordered": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "update", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0, "x": 1 } ] } ] }, { "description": "unacknowledged write concern coll findOneAndDelete", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "findOneAndDelete", "arguments": { "session": "session0", "filter": { "_id": 0 } }, "expectResult": { "_id": 0 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "findAndModify": "test", "query": { "_id": 0 }, "remove": true, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "findAndModify", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [] } ] }, { "description": "unacknowledged write concern coll findOneAndReplace", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "findOneAndReplace", "arguments": { "session": "session0", "filter": { "_id": 0 }, "replacement": { "x": 1 }, "returnDocument": "Before" }, "expectResult": { "_id": 0 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "findAndModify": "test", "query": { "_id": 0 }, "update": { "x": 1 }, "new": { "$$unsetOrMatches": false }, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "findAndModify", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0, "x": 1 } ] } ] }, { "description": "unacknowledged write concern coll findOneAndUpdate", "operations": [ { "object": "session0", "name": "startTransaction" }, { "object": "collection_w0", "name": "findOneAndUpdate", "arguments": { "session": "session0", "filter": { "_id": 0 }, "update": { "$inc": { "x": 1 } }, "returnDocument": "Before" }, "expectResult": { "_id": 0 } }, { "object": "session0", "name": "commitTransaction" } ], "expectEvents": [ { "client": "client0", "events": [ { "commandStartedEvent": { "command": { "findAndModify": "test", "query": { "_id": 0 }, "update": { "$inc": { "x": 1 } }, "new": { "$$unsetOrMatches": false }, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": true, "autocommit": false, "readConcern": { "$$exists": false }, "writeConcern": { "$$exists": false } }, "commandName": "findAndModify", "databaseName": "transaction-tests" } }, { "commandStartedEvent": { "command": { "commitTransaction": 1, "lsid": { "$$sessionLsid": "session0" }, "txnNumber": { "$numberLong": "1" }, "startTransaction": { "$$exists": false }, "autocommit": false, "writeConcern": { "$$exists": false } }, "commandName": "commitTransaction", "databaseName": "admin" } } ] } ], "outcome": [ { "collectionName": "test", "databaseName": "transaction-tests", "documents": [ { "_id": 0, "x": 1 } ] } ] } ] }