diff --git a/jstests/sharding/server-61769.js b/jstests/sharding/server-61769.js new file mode 100644 index 00000000000..3ad376b3927 --- /dev/null +++ b/jstests/sharding/server-61769.js @@ -0,0 +1,35 @@ +(function() { +"use strict"; + +const dbName = "test"; +const collName = "foo"; +const ns = dbName + "." + collName; + +let st = new ShardingTest({shards: 2}); + +assert.commandWorked(st.s.adminCommand({enableSharding: dbName})); +assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 'hashed'}})); + +var session = st.s.startSession(); +var sessionDb = session.getDatabase(dbName); +session.startTransaction(); + +// Note the same occurs with a $merge (e.g. {$merge: {into: 'test.fooOutMerge'}}) +assert.commandFailedWithCode( + sessionDb[collName].runCommand("aggregate", {pipeline: [{$out: "fooOut"}], cursor: {}}), + [ErrorCodes.OperationNotSupportedInTransaction] +); + +session.abortTransaction(); + +assert.soon(() => { + const idleCursors = st.getDB("admin").aggregate( + [{$currentOp: {idleCursors: true}}, {$match: {type: 'idleCursor'}}]).toArray(); + jsTest.log("XXXX - idleCursors length: " + idleCursors.length); + jsTest.log("XXXX - idleCursors: " + tojson(idleCursors)); + return idleCursors.length === 0; + +}); + +st.stop(); +})();