diff options
author | Andrew Chen <andrew.chen@10gen.com> | 2020-03-04 16:50:20 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-04 22:25:41 +0000 |
commit | 9557a35b779a5f6c1a2453514ec9cc67119b288b (patch) | |
tree | b20574eb806c826ec75ce237540bb1b1950f5386 /jstests | |
parent | 82424b742342d4b35cf10eb9d471984d1e805210 (diff) | |
download | mongo-9557a35b779a5f6c1a2453514ec9cc67119b288b.tar.gz |
SERVER-45565: Modified Oplog Batcher behavior to process large transaction oplog entries in separate batches
create mode 100644 jstests/noPassthrough/large_txn_correctness.js
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/large_txn_correctness.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/jstests/noPassthrough/large_txn_correctness.js b/jstests/noPassthrough/large_txn_correctness.js new file mode 100644 index 00000000000..5f240dd3cca --- /dev/null +++ b/jstests/noPassthrough/large_txn_correctness.js @@ -0,0 +1,55 @@ +/** + * This test serves to ensure that the oplog batcher behavior correctly processes large transactions + * so that it does not cause any correctness problems. + * + * @tags: [requires_journaling] + */ +(function() { +"use strict"; +load("jstests/core/txns/libs/prepare_helpers.js"); + +// Declare constants. +const DB_NAME = "db_large_txn_correctness"; +const COLL_NAME = "db_large_txn_correctness"; + +// Make a large document of size 'numMB' so that it can easily fill up an oplog entry. +const makeLargeDoc = numMB => new Array(numMB * 1024 * 1024).join('a'); + +// Spin up a replica set. +const replSet = new ReplSetTest({nodes: 1}); +replSet.startSet(); +replSet.initiate(); +const primary = replSet.getPrimary(); + +const session = primary.startSession(); + +// Creating a collection so the first test can just test if regular CRUD operations work. +session.getDatabase(DB_NAME).createCollection(COLL_NAME); + +let commitRes; + +try { + // Perform a large transaction (>16MB) with only CRUD operations to ensure that nothing + // fundamental is broken. + session.startTransaction(); + session.getDatabase(DB_NAME)[COLL_NAME].insert({doc: makeLargeDoc(10)}); + session.getDatabase(DB_NAME)[COLL_NAME].insert({doc: makeLargeDoc(10)}); + commitRes = session.commitTransaction_forTesting(); + assert.eq(1, commitRes.ok); + + // Ensure that the collection has been dropped so that collection creation can be tested + // in a txn. + session.getDatabase(DB_NAME)[COLL_NAME].drop(); + + // Create a large transaction (>16MB) with a command and ensure that it works. + session.startTransaction(); + session.getDatabase(DB_NAME).createCollection(COLL_NAME); + session.getDatabase(DB_NAME)[COLL_NAME].insert({doc: makeLargeDoc(10)}); + session.getDatabase(DB_NAME)[COLL_NAME].insert({doc: makeLargeDoc(10)}); + commitRes = session.commitTransaction_forTesting(); + assert.eq(1, commitRes.ok); +} finally { + session.endSession(); + replSet.stopSet(); +} +})(); |