summaryrefslogtreecommitdiff
path: root/jstests/core/txns/libs/prepare_helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/txns/libs/prepare_helpers.js')
-rw-r--r--jstests/core/txns/libs/prepare_helpers.js66
1 files changed, 0 insertions, 66 deletions
diff --git a/jstests/core/txns/libs/prepare_helpers.js b/jstests/core/txns/libs/prepare_helpers.js
index 95efbc8bbea..4d87fd9ee07 100644
--- a/jstests/core/txns/libs/prepare_helpers.js
+++ b/jstests/core/txns/libs/prepare_helpers.js
@@ -62,75 +62,9 @@ const PrepareHelpers = (function() {
return session;
}
- const oplogSizeMB = 1;
- const oplogSizeBytes = oplogSizeMB * 1024 * 1024;
- const tenKB = new Array(10 * 1024).join("a");
-
- /**
- * Writes until the oplog exceeds its configured maximum, proving that the node keeps as much
- * oplog as necessary to preserve entries for the oldest active transaction.
- */
- function growOplogPastMaxSize(replSet) {
- const primary = replSet.getPrimary();
- const oplog = primary.getDB("local").oplog.rs;
- assert.lte(oplog.dataSize(), oplogSizeBytes);
- const coll = primary.getDB("growOplogPastMaxSize").growOplogPastMaxSize;
- const numNodes = replSet.nodeList().length;
- while (oplog.dataSize() <= 2 * oplogSizeBytes) {
- assert.commandWorked(coll.insert({tenKB: tenKB}, {writeConcern: {w: numNodes}}));
- }
-
- print(`Oplog on ${primary} dataSize = ${oplog.dataSize()}`);
- }
-
- /**
- * Waits for the oplog to be truncated, proving that once a transaction finishes its oplog
- * entries can be reclaimed.
- */
- function awaitOplogTruncation(replSet) {
- print(`Waiting for oplog to shrink to ${oplogSizeMB} MB`);
- const primary = replSet.getPrimary();
- const primaryOplog = primary.getDB("local").oplog.rs;
- const secondary = replSet.getSecondary();
- const secondaryOplog = secondary.getDB("local").oplog.rs;
-
- // Old entries are reclaimed when oplog size reaches new milestone. With a 1MB oplog,
- // milestones are every 0.1 MB (see WiredTigerRecordStore::OplogStones::OplogStones) so
- // write about 0.2 MB to be certain.
- print("Add writes after transaction finished to trigger oplog reclamation");
- const tenKB = new Array(10 * 1024).join("a");
- const coll = primary.getDB("awaitOplogTruncation").awaitOplogTruncation;
- const numNodes = replSet.nodeList().length;
- for (let i = 0; i < 20; i++) {
- assert.commandWorked(coll.insert({tenKB: tenKB}, {writeConcern: {w: numNodes}}));
- }
-
- for (let [nodeName, oplog] of[["primary", primaryOplog], ["secondary", secondaryOplog]]) {
- assert.soon(function() {
- const dataSize = oplog.dataSize();
- const prepareEntryRemoved = (oplog.findOne({prepare: true}) === null);
- print(`${nodeName} oplog dataSize: ${dataSize},` +
- ` prepare entry removed: ${prepareEntryRemoved}`);
-
- // The oplog milestone system allows the oplog to grow to 110% its max size.
- if (dataSize < 1.1 * oplogSizeBytes && prepareEntryRemoved) {
- return true;
- }
-
- assert.commandWorked(coll.insert({tenKB: tenKB}, {writeConcern: {w: numNodes}}));
- return false;
- }, `waiting for ${nodeName} oplog reclamation`, ReplSetTest.kDefaultTimeoutMS, 1000);
- }
- }
-
return {
prepareTransaction: prepareTransaction,
commitTransaction: commitTransaction,
createSessionWithGivenId: createSessionWithGivenId,
- oplogSizeMB: oplogSizeMB,
- oplogSizeBytes: oplogSizeBytes,
- replSetStartSetOptions: {oplogSize: oplogSizeMB},
- growOplogPastMaxSize: growOplogPastMaxSize,
- awaitOplogTruncation: awaitOplogTruncation
};
})();