diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2018-10-10 10:17:12 -0400 |
---|---|---|
committer | Ted Tuckman <ted.tuckman@mongodb.com> | 2018-10-12 09:45:05 -0400 |
commit | 8e638c938ed3c17d090a85de8b35676af31f8db5 (patch) | |
tree | f1f4047458badda283a3991dee841112b2918bc9 | |
parent | 65eced031a2c8d8b1c5e5815881466b8fbb3bc01 (diff) | |
download | mongo-8e638c938ed3c17d090a85de8b35676af31f8db5.tar.gz |
Remove listLocalCursors
20 files changed, 54 insertions, 308 deletions
diff --git a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml index 21061c18a9a..62549ec9346 100644 --- a/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml +++ b/buildscripts/resmokeconfig/suites/causally_consistent_jscore_passthrough_auth.yml @@ -105,7 +105,6 @@ selector: - jstests/core/drop3.js # Logical sessions require that only one user be authenticated, # but this suite puts us in a multi-auth state. - - jstests/core/list_all_local_cursors.js # Too many users authenticated - jstests/core/list_all_sessions.js # Too many users authenticated - jstests/core/list_sessions.js # Too many users authenticated # The following tests fail because of divergent dropCollection behavior between standalones and diff --git a/buildscripts/resmokeconfig/suites/replica_sets_kill_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_kill_primary_jscore_passthrough.yml index 7bbf4965be9..794e9517859 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_kill_primary_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_kill_primary_jscore_passthrough.yml @@ -102,8 +102,8 @@ selector: # "Refusing to run a test that issues commands that may return different values after a failover" # "Refusing to run a test that issues an aggregation command with explain because it may return # incomplete results" - # "Refusing to run a test that issues an aggregation command with $listLocalCursors or - # $listLocalSessions because they rely on in-memory state that may not survive failovers" + # "Refusing to run a test that issues an aggregation command with + # $listLocalSessions because it relies on in-memory state that may not survive failovers" # "Refusing to run a test that issues a mapReduce command, because it calls std::terminate() if # interrupted by a stepdown" - does_not_support_stepdowns diff --git a/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml index f091d2944f0..5961b4e0614 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_multi_stmt_txn_jscore_passthrough.yml @@ -216,7 +216,6 @@ selector: # Creates sessions explicitly, resulting in txns being run through different sessions # using a single txnNumber. - - jstests/core/list_all_local_cursors.js - jstests/core/json_schema/misc_validation.js - jstests/core/views/views_all_commands.js diff --git a/buildscripts/resmokeconfig/suites/replica_sets_terminate_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_terminate_primary_jscore_passthrough.yml index 7443c8e7665..11dae1e4ef1 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_terminate_primary_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_terminate_primary_jscore_passthrough.yml @@ -102,8 +102,8 @@ selector: # "Refusing to run a test that issues commands that may return different values after a failover" # "Refusing to run a test that issues an aggregation command with explain because it may return # incomplete results" - # "Refusing to run a test that issues an aggregation command with $listLocalCursors or - # $listLocalSessions because they rely on in-memory state that may not survive failovers" + # "Refusing to run a test that issues an aggregation command with + # $listLocalSessions because it relies on in-memory state that may not survive failovers" # "Refusing to run a test that issues a mapReduce command, because it calls std::terminate() if # interrupted by a stepdown" - does_not_support_stepdowns diff --git a/buildscripts/resmokeconfig/suites/retryable_writes_jscore_stepdown_passthrough.yml b/buildscripts/resmokeconfig/suites/retryable_writes_jscore_stepdown_passthrough.yml index 326eec12c4c..716e018bf35 100644 --- a/buildscripts/resmokeconfig/suites/retryable_writes_jscore_stepdown_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/retryable_writes_jscore_stepdown_passthrough.yml @@ -95,8 +95,8 @@ selector: # "Refusing to run a test that issues commands that may return different values after a failover" # "Refusing to run a test that issues an aggregation command with explain because it may return # incomplete results" - # "Refusing to run a test that issues an aggregation command with $listLocalCursors or - # $listLocalSessions because they rely on in-memory state that may not survive failovers" + # "Refusing to run a test that issues an aggregation command with + # $listLocalSessions because it relies on in-memory state that may not survive failovers" # "Refusing to run a test that issues a mapReduce command, because it calls std::terminate() if # interrupted by a stepdown" - does_not_support_stepdowns diff --git a/buildscripts/resmokeconfig/suites/secondary_reads_passthrough.yml b/buildscripts/resmokeconfig/suites/secondary_reads_passthrough.yml index 61213855559..7e22a7b3c97 100644 --- a/buildscripts/resmokeconfig/suites/secondary_reads_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/secondary_reads_passthrough.yml @@ -14,9 +14,6 @@ selector: # These tests attempt to read from the "system.profile" collection, which may be missing entries # if a write was performed on the primary of the replica set instead. - jstests/core/*profile*.js - # Two cursors can be established on different secondaries, so the count of - # $listLocalCursors will not always be 2. - - jstests/core/list_all_local_cursors.js # Tests that fail for Causal Consistency with default injected readPreference 'secondary' # "TODO SERVER-30384: These tests assume that documents are returned in the same order they are diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index 4f402dad1cd..3c2b9e6aec1 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -1413,6 +1413,10 @@ var authCommandsLib = { privileges: [{resource: {cluster: true}, actions: ["inprog"]}] }, { + runOnDb: adminDbName, + privileges: [{resource: {cluster: true}, actions: ["inprog"]}] + }, + { runOnDb: firstDbName, roles: roles_monitoring, privileges: [{resource: {cluster: true}, actions: ["inprog"]}], @@ -1436,15 +1440,6 @@ var authCommandsLib = { testcases: [{runOnDb: adminDbName, roles: roles_all}] }, { - testname: "aggregate_listLocalCursors", - command: {aggregate: 1, pipeline: [{$listLocalCursors: {}}], cursor: {}}, - testcases: [{ - runOnDb: adminDbName, - roles: - {clusterAdmin: 1, clusterMonitor: 1, clusterManager: 1, root: 1, __system: 1} - }], - }, - { testname: "aggregate_listLocalSessions_allUsers_true", command: {aggregate: 1, pipeline: [{$listLocalSessions: {allUsers: true}}], cursor: {}}, testcases: [{ diff --git a/jstests/core/list_all_local_cursors.js b/jstests/core/list_all_local_cursors.js deleted file mode 100644 index 02a5e956ecd..00000000000 --- a/jstests/core/list_all_local_cursors.js +++ /dev/null @@ -1,44 +0,0 @@ -// $listLocalCursors relies on in-memory state, which may not survive failovers. -// @tags: [does_not_support_stepdowns] - -// Basic tests for the $listLocalCursors aggregation stage. - -(function() { - "use strict"; - - const admin = db.getSisterDB("admin"); - function listAllCursorsWithId(cursorId) { - return admin.aggregate([{"$listLocalCursors": {}}, {"$match": {cursorId: cursorId}}]) - .toArray(); - } - - let session = db.getMongo().startSession(); - let testDb = db.getSisterDB("listAllLocalCursors"); - let testDbWithSession = session.getDatabase("listAllLocalCursors"); - testDb.data.drop(); - assert.writeOK(testDb.data.insert({a: 1})); - assert.writeOK(testDb.data.insert({a: 1})); - let cursorIdWithSession = - assert.commandWorked(testDbWithSession.runCommand({find: "data", batchSize: 0})).cursor.id; - let cursorIdWithoutSession = - assert.commandWorked(testDb.runCommand({find: "data", batchSize: 0})).cursor.id; - - // Verify that we correctly list the cursor which is outside of a session. - let foundCursors = listAllCursorsWithId(cursorIdWithoutSession); - assert.eq(foundCursors.length, 1, tojson(foundCursors)); - assert.eq(foundCursors[0].ns, "listAllLocalCursors.data", tojson(foundCursors)); - assert.eq(foundCursors[0].cursorId, cursorIdWithoutSession, tojson(foundCursors)); - - // Verify that we correctly list the cursor which is inside of a session. - foundCursors = listAllCursorsWithId(cursorIdWithSession); - assert.eq(foundCursors.length, 1, tojson(foundCursors)); - assert.eq(foundCursors[0].ns, "listAllLocalCursors.data", tojson(foundCursors)); - assert.eq(foundCursors[0].cursorId, cursorIdWithSession, tojson(foundCursors)); - assert(foundCursors[0].hasOwnProperty("lsid"), tojson(foundCursors)); - assert.eq( - foundCursors[0].lsid.id, session._serverSession.handle.getId().id, tojson(foundCursors)); - - assert.commandWorked(testDbWithSession.runCommand( - {killCursors: "data", cursors: [cursorIdWithSession, cursorIdWithoutSession]})); - session.endSession(); -})(); diff --git a/jstests/libs/kill_sessions.js b/jstests/libs/kill_sessions.js index b69d19ef082..6ee642eddbc 100644 --- a/jstests/libs/kill_sessions.js +++ b/jstests/libs/kill_sessions.js @@ -183,7 +183,8 @@ var _kill_sessions_api_module = (function() { this.visit(function(client) { var db = client.getDB("admin"); db.setSlaveOk(); - var cursors = db.aggregate([{"$listLocalCursors": {}}]).toArray(); + var cursors = + db.aggregate([{"$currentOp": {"idleCursors": true, "allUsers": true}}]).toArray(); cursors.forEach(function(cursor) { assert(!cursor.lsid); }); @@ -203,7 +204,10 @@ var _kill_sessions_api_module = (function() { var db = client.getDB("admin"); db.setSlaveOk(); - var cursors = db.aggregate([{"$listLocalCursors": {}}]).toArray(); + var cursors = db.aggregate([ + {"$currentOp": {"idleCursors": true, "allUsers": true}}, + {"$match": {type: "idleCursor"}} + ]).toArray(); cursors.forEach(function(cursor) { if (cursor.lsid) { checkNotExist.forEach(function(handle) { @@ -218,8 +222,7 @@ var _kill_sessions_api_module = (function() { } } }); - - assert.eq(needToFind.length, 0); + assert.eq(needToFind.length, 0, cursors); }); }; diff --git a/jstests/libs/override_methods/auto_retry_on_network_error.js b/jstests/libs/override_methods/auto_retry_on_network_error.js index a37f9d1650e..a20614583ac 100644 --- a/jstests/libs/override_methods/auto_retry_on_network_error.js +++ b/jstests/libs/override_methods/auto_retry_on_network_error.js @@ -185,17 +185,15 @@ } else if (cmdName === "aggregate") { var stages = cmdObj.pipeline; - // $listLocalCursors and $listLocalSessions must be the first stage in the pipeline. + // $listLocalSessions must be the first stage in the pipeline. const firstStage = stages && Array.isArray(stages) && (stages.length > 0) ? stages[0] : undefined; const hasListLocalStage = firstStage && (typeof firstStage === "object") && - (firstStage.hasOwnProperty("$listLocalCursors") || - firstStage.hasOwnProperty("$listLocalSessions")); + firstStage.hasOwnProperty("$listLocalSessions"); if (hasListLocalStage) { - throw new Error( - "Refusing to run a test that issues an aggregation command with" + - " $listLocalCursors or $listLocalSessions because they rely on in-memory" + - " state that may not survive failovers."); + throw new Error("Refusing to run a test that issues an aggregation command with" + + " $listLocalSessions because it relies on in-memory" + + " state that may not survive failovers."); } // Aggregate can be either a read or a write depending on whether it has a $out stage. diff --git a/jstests/libs/override_methods/override_helpers.js b/jstests/libs/override_methods/override_helpers.js index 437f1a07669..94d7f72cb06 100644 --- a/jstests/libs/override_methods/override_helpers.js +++ b/jstests/libs/override_methods/override_helpers.js @@ -97,8 +97,6 @@ var OverrideHelpers = (function() { } return { - isAggregationWithListLocalCursorsStage: - makeIsAggregationWithFirstStage("$listLocalCursors"), isAggregationWithListLocalSessionsStage: makeIsAggregationWithFirstStage("$listLocalSessions"), isAggregationWithOutStage: isAggregationWithOutStage, diff --git a/jstests/libs/override_methods/set_read_and_write_concerns.js b/jstests/libs/override_methods/set_read_and_write_concerns.js index b68d6c1c5a4..2e9c5875ce6 100644 --- a/jstests/libs/override_methods/set_read_and_write_concerns.js +++ b/jstests/libs/override_methods/set_read_and_write_concerns.js @@ -129,12 +129,6 @@ } } if (commandName === "aggregate") { - if (OverrideHelpers.isAggregationWithListLocalCursorsStage(commandName, - commandObjUnwrapped)) { - // The $listLocalCursors stage can only be used with readConcern={level: "local"}. - shouldForceReadConcern = false; - } - if (OverrideHelpers.isAggregationWithListLocalSessionsStage(commandName, commandObjUnwrapped)) { // The $listLocalSessions stage can only be used with readConcern={level: "local"}. diff --git a/jstests/noPassthrough/aggregation_cursor_invalidations.js b/jstests/noPassthrough/aggregation_cursor_invalidations.js index dcb0610dc26..387fbe56952 100644 --- a/jstests/noPassthrough/aggregation_cursor_invalidations.js +++ b/jstests/noPassthrough/aggregation_cursor_invalidations.js @@ -53,13 +53,18 @@ } // Check that there are no cursors still open on the source collection. If any are found, the - // test will fail and print the output of $listLocalCursors. This should be called each time we + // test will fail and print a list of idle cursors. This should be called each time we // expect a cursor to have been destroyed. function assertNoOpenCursorsOnSourceCollection() { const cursors = - testDB - .aggregate( - [{"$listLocalCursors": {}}, {$match: {ns: sourceCollection.getFullName()}}]) + testDB.getSiblingDB("admin") + .aggregate([ + {"$currentOp": {"idleCursors": true}}, + { + "$match": {ns: sourceCollection.getFullName(), "type": "idleCursor"} + + } + ]) .toArray(); assert.eq( cursors.length, 0, "Did not expect to find any cursors, but found " + tojson(cursors)); diff --git a/jstests/noPassthrough/read_concern_snapshot_aggregation.js b/jstests/noPassthrough/read_concern_snapshot_aggregation.js index 838b3ddd9b2..9c36b6ebf2e 100644 --- a/jstests/noPassthrough/read_concern_snapshot_aggregation.js +++ b/jstests/noPassthrough/read_concern_snapshot_aggregation.js @@ -52,10 +52,6 @@ testSnapshotAggFailsWithCode( kCollName, [{$indexStats: {}}], ErrorCodes.OperationNotSupportedInTransaction); - // Test that $listLocalCursors is disallowed with transactions. - testSnapshotAggFailsWithCode( - 1, [{$listLocalCursors: {}}], ErrorCodes.OperationNotSupportedInTransaction); - // Test that $listLocalSessions is disallowed with transactions. testSnapshotAggFailsWithCode( 1, [{$listLocalSessions: {}}], ErrorCodes.OperationNotSupportedInTransaction); diff --git a/jstests/sharding/change_streams_shards_start_in_sync.js b/jstests/sharding/change_streams_shards_start_in_sync.js index c3c3fb07e73..6146a19fe9f 100644 --- a/jstests/sharding/change_streams_shards_start_in_sync.js +++ b/jstests/sharding/change_streams_shards_start_in_sync.js @@ -89,12 +89,14 @@ // Wait for the aggregate cursor to appear in currentOp on the current shard. function waitForShardCursor(rs) { - assert.soon( - () => st.rs0.getPrimary() - .getDB('admin') - .aggregate( - [{"$listLocalCursors": {}}, {"$match": {ns: mongosColl.getFullName()}}]) - .itcount() === 1); + assert.soon(() => st.rs0.getPrimary() + .getDB('admin') + .aggregate([ + {"$currentOp": {"idleCursors": true}}, + {"$match": {ns: mongosColl.getFullName(), type: "idleCursor"}} + + ]) + .itcount() === 1); } // Make sure the shard 0 $changeStream cursor is established before doing the first writes. waitForShardCursor(st.rs0); diff --git a/jstests/sharding/mongos_local_explain.js b/jstests/sharding/mongos_local_explain.js index 0200c334d85..bf9ab379e53 100644 --- a/jstests/sharding/mongos_local_explain.js +++ b/jstests/sharding/mongos_local_explain.js @@ -8,30 +8,25 @@ const st = new ShardingTest({name: "mongos_comment_test", mongos: 1, shards: 1}); const mongosConn = st.s; - // MongoS-only stages to be tested and the expected 'explain' output for that stage. - const testStages = { - "$listLocalSessions": {allUsers: false, users: [{user: "nobody", db: "nothing"}]}, - "$listLocalCursors": {} + const stageSpec = { + "$listLocalSessions": {allUsers: false, users: [{user: "nobody", db: "nothing"}]} }; - for (let stage in testStages) { - // Use the test stage to create a pipeline that runs exclusively on mongoS. - const mongosOnlyPipeline = [{[stage]: testStages[stage]}, {$match: {dummyField: 1}}]; + // Use the test stage to create a pipeline that runs exclusively on mongoS. + const mongosOnlyPipeline = [stageSpec, {$match: {dummyField: 1}}]; - // We expect the explain output to reflect the stage's spec. - const expectedExplainStages = - [{[stage]: testStages[stage]}, {$match: {dummyField: {$eq: 1}}}]; + // We expect the explain output to reflect the stage's spec. + const expectedExplainStages = [stageSpec, {$match: {dummyField: {$eq: 1}}}]; - // Test that the mongoS-only pipeline is explainable. - const explainPlan = assert.commandWorked(mongosConn.getDB("admin").runCommand( - {aggregate: 1, pipeline: mongosOnlyPipeline, explain: true})); + // Test that the mongoS-only pipeline is explainable. + const explainPlan = assert.commandWorked(mongosConn.getDB("admin").runCommand( + {aggregate: 1, pipeline: mongosOnlyPipeline, explain: true})); - // We expect the stages to appear under the 'mongos' heading, for 'splitPipeline' to be - // null, and for the 'mongos.host' field to be the hostname:port of the mongoS itself. - assert.docEq(explainPlan.mongos.stages, expectedExplainStages); - assert.eq(explainPlan.mongos.host, mongosConn.name); - assert.isnull(explainPlan.splitPipeline); - } + // We expect the stages to appear under the 'mongos' heading, for 'splitPipeline' to be + // null, and for the 'mongos.host' field to be the hostname:port of the mongoS itself. + assert.docEq(explainPlan.mongos.stages, expectedExplainStages); + assert.eq(explainPlan.mongos.host, mongosConn.name); + assert.isnull(explainPlan.splitPipeline); st.stop(); -})();
\ No newline at end of file +})(); diff --git a/src/mongo/db/auth/role_graph_builtin_roles.cpp b/src/mongo/db/auth/role_graph_builtin_roles.cpp index d9875a20f96..589a4feb0e8 100644 --- a/src/mongo/db/auth/role_graph_builtin_roles.cpp +++ b/src/mongo/db/auth/role_graph_builtin_roles.cpp @@ -182,7 +182,6 @@ MONGO_INITIALIZER(AuthorizationBuiltinRoles)(InitializerContext* context) { << ActionType::getParameter << ActionType::getShardMap << ActionType::hostInfo - << ActionType::listCursors // clusterManager gets this also << ActionType::listDatabases << ActionType::listSessions // clusterManager gets this also << ActionType::listShards // clusterManager gets this also @@ -238,7 +237,6 @@ MONGO_INITIALIZER(AuthorizationBuiltinRoles)(InitializerContext* context) { << ActionType::resync // hostManager gets this also << ActionType::addShard << ActionType::removeShard - << ActionType::listCursors // clusterManager gets this also << ActionType::listSessions // clusterMonitor gets this also << ActionType::listShards // clusterMonitor gets this also << ActionType::flushRouterConfig // hostManager gets this also diff --git a/src/mongo/db/pipeline/SConscript b/src/mongo/db/pipeline/SConscript index 1e07bb15e4f..c236e273752 100644 --- a/src/mongo/db/pipeline/SConscript +++ b/src/mongo/db/pipeline/SConscript @@ -361,7 +361,6 @@ pipelineeEnv.Library( 'document_source_internal_split_pipeline.cpp', 'document_source_limit.cpp', 'document_source_list_cached_and_active_users.cpp', - 'document_source_list_local_cursors.cpp', 'document_source_list_local_sessions.cpp', 'document_source_list_sessions.cpp', 'document_source_lookup.cpp', diff --git a/src/mongo/db/pipeline/document_source_list_local_cursors.cpp b/src/mongo/db/pipeline/document_source_list_local_cursors.cpp deleted file mode 100644 index 4e63c792df8..00000000000 --- a/src/mongo/db/pipeline/document_source_list_local_cursors.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (C) 2017 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects - * for all of the code used other than as permitted herein. If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. If you - * delete this exception statement from all source files in the program, - * then also delete it in the license file. - */ - -#include "mongo/platform/basic.h" - -#include "mongo/db/pipeline/document_source_list_local_cursors.h" - -#include "mongo/db/auth/authorization_session.h" -#include "mongo/db/auth/user_name.h" -#include "mongo/db/commands/test_commands_enabled.h" -#include "mongo/db/logical_session_id_helpers.h" - -namespace mongo { - -REGISTER_TEST_DOCUMENT_SOURCE(listLocalCursors, - DocumentSourceListLocalCursors::LiteParsed::parse, - DocumentSourceListLocalCursors::createFromBson); - -const char* DocumentSourceListLocalCursors::kStageName = "$listLocalCursors"; - -DocumentSource::GetNextResult DocumentSourceListLocalCursors::getNext() { - pExpCtx->checkForInterrupt(); - - if (!_cursors.empty()) { - Document doc(_cursors.back().toBSON()); - _cursors.pop_back(); - return std::move(doc); - } - - return GetNextResult::makeEOF(); -} - -boost::intrusive_ptr<DocumentSource> DocumentSourceListLocalCursors::createFromBson( - BSONElement spec, const boost::intrusive_ptr<ExpressionContext>& pExpCtx) { - - uassert(ErrorCodes::BadValue, - str::stream() << kStageName << " must be run as { " << kStageName << ": {}}", - spec.isABSONObj() && spec.Obj().isEmpty()); - - return new DocumentSourceListLocalCursors(pExpCtx); -} - -DocumentSourceListLocalCursors::DocumentSourceListLocalCursors( - const boost::intrusive_ptr<ExpressionContext>& pExpCtx) - : DocumentSource(pExpCtx), - _cursors(pExpCtx->mongoProcessInterface->getIdleCursors( - pExpCtx, MongoProcessInterface::CurrentOpUserMode::kIncludeAll)) {} -} diff --git a/src/mongo/db/pipeline/document_source_list_local_cursors.h b/src/mongo/db/pipeline/document_source_list_local_cursors.h deleted file mode 100644 index 1725cc70f44..00000000000 --- a/src/mongo/db/pipeline/document_source_list_local_cursors.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright (C) 2017 MongoDB Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects - * for all of the code used other than as permitted herein. If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. If you - * delete this exception statement from all source files in the program, - * then also delete it in the license file. - */ - -#pragma once - -#include <vector> - -#include "mongo/bson/bsonmisc.h" -#include "mongo/bson/bsonobj.h" -#include "mongo/db/generic_cursor.h" -#include "mongo/db/pipeline/document_source.h" -#include "mongo/db/pipeline/lite_parsed_document_source.h" - -namespace mongo { - -/** - * Produces one document per session in the local cache if 'allUsers' is specified - * as true, and returns just sessions for the currently logged in user if - * 'allUsers' is specified as false, or not specified at all. - */ -class DocumentSourceListLocalCursors final : public DocumentSource { -public: - static const char* kStageName; - - class LiteParsed final : public LiteParsedDocumentSource { - public: - static std::unique_ptr<LiteParsed> parse(const AggregationRequest& request, - const BSONElement& spec) { - return stdx::make_unique<LiteParsed>(); - } - - stdx::unordered_set<NamespaceString> getInvolvedNamespaces() const final { - return stdx::unordered_set<NamespaceString>(); - } - - PrivilegeVector requiredPrivileges(bool isMongos) const final { - return {Privilege(ResourcePattern::forClusterResource(), ActionType::listCursors)}; - } - - bool isInitialSource() const final { - return true; - } - - bool allowedToForwardFromMongos() const final { - return false; - } - - void assertSupportsReadConcern(const repl::ReadConcernArgs& readConcern) const { - uassert(ErrorCodes::InvalidOptions, - str::stream() << "Aggregation stage " << kStageName << " cannot run with a " - << "readConcern other than 'local', or in a multi-document " - << "transaction. Current readConcern: " - << readConcern.toString(), - readConcern.getLevel() == repl::ReadConcernLevel::kLocalReadConcern); - } - }; - - GetNextResult getNext() final; - - const char* getSourceName() const final { - return kStageName; - } - - Value serialize(boost::optional<ExplainOptions::Verbosity> explain = boost::none) const final { - return Value(Document{{getSourceName(), Document{}}}); - } - - StageConstraints constraints(Pipeline::SplitState pipeState) const final { - StageConstraints constraints(StreamType::kStreaming, - PositionRequirement::kFirst, - HostTypeRequirement::kLocalOnly, - DiskUseRequirement::kNoDiskUse, - FacetRequirement::kNotAllowed, - TransactionRequirement::kNotAllowed); - - constraints.isIndependentOfAnyCollection = true; - constraints.requiresInputDocSource = false; - return constraints; - } - - static boost::intrusive_ptr<DocumentSource> createFromBson( - BSONElement elem, const boost::intrusive_ptr<ExpressionContext>& pExpCtx); - -private: - DocumentSourceListLocalCursors(const boost::intrusive_ptr<ExpressionContext>& pExpCtx); - - std::vector<GenericCursor> _cursors; -}; - -} // namespace mongo |