diff options
author | James Wahlin <james@mongodb.com> | 2018-03-07 09:34:12 -0500 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2018-03-12 15:06:57 -0400 |
commit | 47421498cc181ffc1bc30191ca64d51f0be7715c (patch) | |
tree | 3158ee6b2a91d68de4a604ff50210fe5c6ca5d2f /jstests/noPassthrough/readConcern_snapshot.js | |
parent | 4df8c9134d3202379bf4d07d7ee10ab3fcfbfe69 (diff) | |
download | mongo-47421498cc181ffc1bc30191ca64d51f0be7715c.tar.gz |
SERVER-33705 Add snapshot read support for findAndModify
Diffstat (limited to 'jstests/noPassthrough/readConcern_snapshot.js')
-rw-r--r-- | jstests/noPassthrough/readConcern_snapshot.js | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/jstests/noPassthrough/readConcern_snapshot.js b/jstests/noPassthrough/readConcern_snapshot.js index 2257f6641bf..94ca9383fcf 100644 --- a/jstests/noPassthrough/readConcern_snapshot.js +++ b/jstests/noPassthrough/readConcern_snapshot.js @@ -225,16 +225,34 @@ txnNumber: NumberLong(txnNumber++) })); - // readConcern 'snapshot' is not supported by findAndModify. - // TODO SERVER-33354: Add snapshot support for findAndModify. - assert.commandFailedWithCode(sessionDb.runCommand({ + // TODO SERVER-33591: Remove once snapshot writes use majority writeConcern. + // Perform majority write to ensure any previous writes are part of the majority commit + // snapshot. + assert.commandWorked(sessionDb.coll.insert({}, {writeConcern: {w: "majority"}})); + + // readConcern 'snapshot' is supported by findAndModify. + assert.commandWorked(sessionDb.runCommand({ findAndModify: collName, - filter: {}, - update: {$set: {a: 1}}, + query: {_id: 1}, + update: {$set: {b: 1}}, readConcern: {level: "snapshot"}, - txnNumber: NumberLong(txnNumber++) - }), - ErrorCodes.InvalidOptions); + txnNumber: NumberLong(txnNumber++), + })); + assert.eq({_id: 1, a: 1, b: 1}, sessionDb.coll.findOne({_id: 1})); + + // TODO SERVER-33591: Remove once snapshot writes use majority writeConcern. + // Perform majority write to ensure any previous writes are part of the majority commit + // snapshot. + assert.commandWorked(sessionDb.coll.insert({}, {writeConcern: {w: "majority"}})); + + assert.commandWorked(sessionDb.runCommand({ + findAndModify: collName, + query: {_id: 1}, + remove: true, + readConcern: {level: "snapshot"}, + txnNumber: NumberLong(txnNumber++), + })); + assert.eq(0, sessionDb.coll.find({_id: 1}).itcount()); // readConcern 'snapshot' is supported by parallelCollectionScan. assert.commandWorked(sessionDb.runCommand({ |