summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2018-08-06 11:31:54 -0400
committerjannaerin <golden.janna@gmail.com>2018-08-28 17:48:50 -0400
commit145f3a4368ac2efe92d58ddb2462229e5c27365c (patch)
tree38f118614d112bfa26e172e4c69e9a75eed0fe6f /src/mongo/shell
parent69de1dd12074380806295d6830937625d581af1b (diff)
downloadmongo-145f3a4368ac2efe92d58ddb2462229e5c27365c.tar.gz
SERVER-36306 Add FSM workloads that run transactions workloads with all threads using same session
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/assert.js9
-rw-r--r--src/mongo/shell/session.js13
2 files changed, 19 insertions, 3 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index 4e6b762475a..de7bb1219a6 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -617,6 +617,15 @@ assert = (function() {
return res;
}
+ assert.commandWorkedOrFailedWithCode = function commandWorkedOrFailedWithCode(
+ res, errorCodeSet, msg) {
+ if (!res.ok) {
+ return assert.commandFailedWithCode(res, errorCodeSet, msg);
+ } else {
+ return assert.commandWorked(res, msg);
+ }
+ };
+
assert.commandWorked = function(res, msg) {
return _assertCommandWorked(res, msg, {ignoreWriteErrors: false});
};
diff --git a/src/mongo/shell/session.js b/src/mongo/shell/session.js
index b786d0583ae..d89be37b8e3 100644
--- a/src/mongo/shell/session.js
+++ b/src/mongo/shell/session.js
@@ -736,9 +736,11 @@ var {
return cmdObj;
};
- this.startTransaction = function startTransaction(txnOptsObj) {
- // If the session is already in a transaction, raise an error.
- if (this.isTxnActive()) {
+ this.startTransaction = function startTransaction(txnOptsObj, ignoreActiveTxn) {
+ // If the session is already in a transaction, raise an error. If retryNewTxnNum
+ // is true, don't raise an error. This is to allow multiple threads to try to
+ // use the same session in a concurrency workload.
+ if (this.isTxnActive() && !ignoreActiveTxn) {
throw new Error("Transaction already in progress on this session.");
}
if (!serverSupports(kWireVersionSupportingMultiDocumentTransactions)) {
@@ -941,6 +943,11 @@ var {
this._serverSession.startTransaction(txnOptsObj);
};
+ this.startTransaction_forTesting = function startTransaction_forTesting(
+ txnOptsObj = {}, {ignoreActiveTxn: ignoreActiveTxn = false} = {}) {
+ this._serverSession.startTransaction(txnOptsObj, ignoreActiveTxn);
+ };
+
this.commitTransaction = function commitTransaction() {
assert.commandWorked(this._serverSession.commitTransaction(this));
};