Moves registration of aggregation cursors to the global cursor manager. This simplifies the logic for acquiring locks and resolving view namespaces within the getMore and killCursors commands.
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
// Confirms that a parallelCollectionScan command and subsequent getMores of its cursor are profiled
|
|
// correctly.
|
|
|
|
(function() {
|
|
"use strict";
|
|
|
|
// For getLatestProfilerEntry and getProfilerProtocolStringForCommand.
|
|
load("jstests/libs/profiler.js");
|
|
|
|
var testDB = db.getSiblingDB("profile_parallel_collection_scan");
|
|
var testColl = testDB.testColl;
|
|
assert.commandWorked(testDB.dropDatabase());
|
|
|
|
// Insert some data to scan over.
|
|
assert.writeOK(testColl.insert([{}, {}, {}, {}]));
|
|
|
|
testDB.setProfilingLevel(2);
|
|
|
|
const parallelCollectionScanCmd = {parallelCollectionScan: testColl.getName(), numCursors: 1};
|
|
const profileEntryFilter = {op: "command", command: parallelCollectionScanCmd};
|
|
|
|
let cmdRes = assert.commandWorked(testDB.runCommand(parallelCollectionScanCmd));
|
|
|
|
assert.eq(testDB.system.profile.find(profileEntryFilter).itcount(),
|
|
1,
|
|
"expected to find profile entry for a parallelCollectionScan command");
|
|
|
|
const firstCursor = cmdRes.cursors[0].cursor;
|
|
const getMoreCollName = firstCursor.ns.substr(firstCursor.ns.indexOf(".") + 1);
|
|
cmdRes = assert.commandWorked(
|
|
testDB.runCommand({getMore: firstCursor.id, collection: getMoreCollName}));
|
|
|
|
const getMoreProfileEntry = getLatestProfilerEntry(testDB, {op: "getmore"});
|
|
assert.eq(getMoreProfileEntry.originatingCommand, parallelCollectionScanCmd);
|
|
})();
|