summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
authorJacob Evans <jacob.evans@10gen.com>2018-11-09 18:10:56 -0500
committerJacob Evans <jacob.evans@10gen.com>2019-01-08 13:03:46 -0500
commitd155173622a2160471610749eff59f7a15003489 (patch)
treeb7a23045b39b8799e63a13decb345351c7b6bf7e /jstests/sharding
parent00728fb39267f5ca7c6bdc3bb69d2e445b5c3c29 (diff)
downloadmongo-d155173622a2160471610749eff59f7a15003489.tar.gz
SERVER-37947 Fail gracefully when explain is used in transactions
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/aggregation_currentop.js11
-rw-r--r--jstests/sharding/explain_cmd.js15
2 files changed, 18 insertions, 8 deletions
diff --git a/jstests/sharding/aggregation_currentop.js b/jstests/sharding/aggregation_currentop.js
index f6f114f1e82..ef629106f23 100644
--- a/jstests/sharding/aggregation_currentop.js
+++ b/jstests/sharding/aggregation_currentop.js
@@ -331,20 +331,15 @@ TestData.skipAwaitingReplicationOnShardsBeforeCheckingUUIDs = true;
}));
// Test that $currentOp fails if a non-local readConcern is specified for any data-bearing
- // target. When run on a mongoS with {localOps:true}, read concern is not applicable and is
- // therefore ignored.
+ // target.
const linearizableAggCmd = {
aggregate: 1,
pipeline: [{$currentOp: curOpSpec}],
readConcern: {level: "linearizable"},
cursor: {}
};
- if (isLocalMongosCurOp) {
- assert.commandWorked(adminDB.runCommand(linearizableAggCmd));
- } else {
- assert.commandFailedWithCode(adminDB.runCommand(linearizableAggCmd),
- ErrorCodes.InvalidOptions);
- }
+ assert.commandFailedWithCode(adminDB.runCommand(linearizableAggCmd),
+ ErrorCodes.InvalidOptions);
// Test that {idleConnections: false} returns only active connections.
const idleConn = new Mongo(conn.host);
diff --git a/jstests/sharding/explain_cmd.js b/jstests/sharding/explain_cmd.js
index dece5acff72..2c5f63753b7 100644
--- a/jstests/sharding/explain_cmd.js
+++ b/jstests/sharding/explain_cmd.js
@@ -141,5 +141,20 @@
});
assert.commandFailed(explain, tojson(explain));
+ // Explain a changeStream, ensure an error is thrown under snapshot read concern which is the
+ // default read concern for a transaction.
+ const session = db.getMongo().startSession();
+ const sessionDB = session.getDatabase(db.getName());
+ explain = sessionDB.runCommand({
+ aggregate: "coll",
+ pipeline: [{$changeStream: {}}],
+ explain: true,
+ txnNumber: NumberLong(0),
+ startTransaction: true,
+ autocommit: false
+ });
+ assert.commandFailedWithCode(
+ explain, ErrorCodes.OperationNotSupportedInTransaction, tojson(explain));
+
st.stop();
})();