summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2018-01-31 14:30:51 -0500
committerJudah Schvimer <judah@mongodb.com>2018-01-31 14:30:51 -0500
commitd75cb425fbc3cf4b569eb1722c3f8abec45654a2 (patch)
tree95f285d0be51aeafbb22d1ac37bb615df28f20b7 /src/mongo/db/commands
parentbe24b0323d3f2d424d9e22337f4221d39001ac31 (diff)
downloadmongo-d75cb425fbc3cf4b569eb1722c3f8abec45654a2.tar.gz
Revert "SERVER-32958 slaveOk,slaveOverrideOk replacement"
This reverts commit be24b0323d3f2d424d9e22337f4221d39001ac31.
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/SConscript1
-rw-r--r--src/mongo/db/commands/apply_ops_cmd.cpp4
-rw-r--r--src/mongo/db/commands/authentication_commands.cpp8
-rw-r--r--src/mongo/db/commands/authentication_commands.h4
-rw-r--r--src/mongo/db/commands/clone.cpp5
-rw-r--r--src/mongo/db/commands/clone_collection.cpp5
-rw-r--r--src/mongo/db/commands/collection_to_capped.cpp8
-rw-r--r--src/mongo/db/commands/compact.cpp4
-rw-r--r--src/mongo/db/commands/conn_pool_stats.cpp4
-rw-r--r--src/mongo/db/commands/conn_pool_sync.cpp4
-rw-r--r--src/mongo/db/commands/connection_status.cpp4
-rw-r--r--src/mongo/db/commands/copydb.cpp4
-rw-r--r--src/mongo/db/commands/copydb_start_commands.cpp5
-rw-r--r--src/mongo/db/commands/count_cmd.cpp13
-rw-r--r--src/mongo/db/commands/cpuload.cpp4
-rw-r--r--src/mongo/db/commands/cpuprofile.cpp4
-rw-r--r--src/mongo/db/commands/create_indexes.cpp6
-rw-r--r--src/mongo/db/commands/current_op_common.h4
-rw-r--r--src/mongo/db/commands/dbcheck.cpp4
-rw-r--r--src/mongo/db/commands/dbcommands.cpp48
-rw-r--r--src/mongo/db/commands/dbhash.cpp4
-rw-r--r--src/mongo/db/commands/distinct.cpp8
-rw-r--r--src/mongo/db/commands/do_txn_cmd.cpp4
-rw-r--r--src/mongo/db/commands/driverHelpers.cpp8
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp10
-rw-r--r--src/mongo/db/commands/end_sessions_command.cpp4
-rw-r--r--src/mongo/db/commands/eval.cpp4
-rw-r--r--src/mongo/db/commands/explain_cmd.cpp25
-rw-r--r--src/mongo/db/commands/fail_point_cmd.cpp5
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp4
-rw-r--r--src/mongo/db/commands/find_cmd.cpp8
-rw-r--r--src/mongo/db/commands/fsync.cpp8
-rw-r--r--src/mongo/db/commands/generic.cpp75
-rw-r--r--src/mongo/db/commands/geo_near_cmd.cpp7
-rw-r--r--src/mongo/db/commands/get_last_error.cpp12
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp4
-rw-r--r--src/mongo/db/commands/group_cmd.cpp8
-rw-r--r--src/mongo/db/commands/hashcmd.cpp4
-rw-r--r--src/mongo/db/commands/haystack.cpp8
-rw-r--r--src/mongo/db/commands/index_filter_commands.cpp8
-rw-r--r--src/mongo/db/commands/index_filter_commands.h4
-rw-r--r--src/mongo/db/commands/isself.cpp4
-rw-r--r--src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp4
-rw-r--r--src/mongo/db/commands/kill_all_sessions_command.cpp4
-rw-r--r--src/mongo/db/commands/kill_op.cpp4
-rw-r--r--src/mongo/db/commands/kill_sessions_command.cpp4
-rw-r--r--src/mongo/db/commands/killcursors_common.h4
-rw-r--r--src/mongo/db/commands/list_collections.cpp7
-rw-r--r--src/mongo/db/commands/list_databases.cpp7
-rw-r--r--src/mongo/db/commands/list_indexes.cpp7
-rw-r--r--src/mongo/db/commands/lock_info.cpp8
-rw-r--r--src/mongo/db/commands/mr.cpp27
-rw-r--r--src/mongo/db/commands/oplog_note.cpp4
-rw-r--r--src/mongo/db/commands/parallel_collection_scan.cpp4
-rw-r--r--src/mongo/db/commands/parameters.cpp8
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp8
-rw-r--r--src/mongo/db/commands/plan_cache_commands.cpp8
-rw-r--r--src/mongo/db/commands/plan_cache_commands.h4
-rw-r--r--src/mongo/db/commands/reap_logical_session_cache_now.cpp4
-rw-r--r--src/mongo/db/commands/refresh_logical_session_cache_now.cpp4
-rw-r--r--src/mongo/db/commands/refresh_sessions_command.cpp4
-rw-r--r--src/mongo/db/commands/refresh_sessions_command_internal.cpp4
-rw-r--r--src/mongo/db/commands/rename_collection_cmd.cpp4
-rw-r--r--src/mongo/db/commands/repair_cursor.cpp4
-rw-r--r--src/mongo/db/commands/resize_oplog.cpp4
-rw-r--r--src/mongo/db/commands/server_status.cpp4
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp4
-rw-r--r--src/mongo/db/commands/shutdown.h4
-rw-r--r--src/mongo/db/commands/snapshot_management.cpp8
-rw-r--r--src/mongo/db/commands/start_session_command.cpp4
-rw-r--r--src/mongo/db/commands/test_commands.cpp16
-rw-r--r--src/mongo/db/commands/top_command.cpp4
-rw-r--r--src/mongo/db/commands/touch.cpp4
-rw-r--r--src/mongo/db/commands/user_management_commands.cpp84
-rw-r--r--src/mongo/db/commands/validate.cpp4
-rw-r--r--src/mongo/db/commands/write_commands/write_commands.cpp4
76 files changed, 351 insertions, 298 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 378e475dc44..36107dce430 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -212,7 +212,6 @@ env.Library(
'$BUILD_DIR/mongo/db/catalog/collection',
'$BUILD_DIR/mongo/db/catalog/index_key_validate',
'$BUILD_DIR/mongo/db/cloner',
- '$BUILD_DIR/mongo/db/command_can_run_here',
'$BUILD_DIR/mongo/db/commands',
'$BUILD_DIR/mongo/db/exec/stagedebug_cmd',
'$BUILD_DIR/mongo/db/index/index_access_method',
diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp
index d0bce7a629e..f2b41250973 100644
--- a/src/mongo/db/commands/apply_ops_cmd.cpp
+++ b/src/mongo/db/commands/apply_ops_cmd.cpp
@@ -202,8 +202,8 @@ class ApplyOpsCmd : public BasicCommand {
public:
ApplyOpsCmd() : BasicCommand("applyOps") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ bool slaveOk() const override {
+ return false;
}
bool supportsWriteConcern(const BSONObj& cmd) const override {
diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp
index 0b925c3d84c..58e34b87f9d 100644
--- a/src/mongo/db/commands/authentication_commands.cpp
+++ b/src/mongo/db/commands/authentication_commands.cpp
@@ -97,8 +97,8 @@ class CmdGetNonce : public BasicCommand {
public:
CmdGetNonce() : BasicCommand("getnonce"), _random(SecureRandom::create()) {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const final {
+ return true;
}
std::string help() const final {
@@ -259,8 +259,8 @@ CmdAuthenticate cmdAuthenticate;
class CmdLogout : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
diff --git a/src/mongo/db/commands/authentication_commands.h b/src/mongo/db/commands/authentication_commands.h
index 5e886827256..a5123fb932b 100644
--- a/src/mongo/db/commands/authentication_commands.h
+++ b/src/mongo/db/commands/authentication_commands.h
@@ -40,8 +40,8 @@ class CmdAuthenticate : public BasicCommand {
public:
static void disableAuthMechanism(std::string authMechanism);
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
std::string help() const override {
return "internal";
diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp
index 0e50419a5df..e7ec4973221 100644
--- a/src/mongo/db/commands/clone.cpp
+++ b/src/mongo/db/commands/clone.cpp
@@ -56,10 +56,11 @@ class CmdClone : public BasicCommand {
public:
CmdClone() : BasicCommand("clone") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
}
diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp
index 493ea75d044..0a8ddde8bea 100644
--- a/src/mongo/db/commands/clone_collection.cpp
+++ b/src/mongo/db/commands/clone_collection.cpp
@@ -63,10 +63,11 @@ class CmdCloneCollection : public ErrmsgCommandDeprecated {
public:
CmdCloneCollection() : ErrmsgCommandDeprecated("cloneCollection") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
}
diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp
index 56dad067123..14a3bf3f00e 100644
--- a/src/mongo/db/commands/collection_to_capped.cpp
+++ b/src/mongo/db/commands/collection_to_capped.cpp
@@ -52,8 +52,8 @@ using std::stringstream;
class CmdCloneCollectionAsCapped : public ErrmsgCommandDeprecated {
public:
CmdCloneCollectionAsCapped() : ErrmsgCommandDeprecated("cloneCollectionAsCapped") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
@@ -151,8 +151,8 @@ public:
class CmdConvertToCapped : public ErrmsgCommandDeprecated {
public:
CmdConvertToCapped() : ErrmsgCommandDeprecated("convertToCapped") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index 4a52700118c..e914d2f606d 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -61,8 +61,8 @@ public:
virtual bool adminOnly() const {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool maintenanceMode() const {
return true;
diff --git a/src/mongo/db/commands/conn_pool_stats.cpp b/src/mongo/db/commands/conn_pool_stats.cpp
index e799257d923..298bbda74d4 100644
--- a/src/mongo/db/commands/conn_pool_stats.cpp
+++ b/src/mongo/db/commands/conn_pool_stats.cpp
@@ -53,8 +53,8 @@ public:
return "stats about connections between servers in a replica set or sharded cluster.";
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool supportsWriteConcern(const BSONObj& cmd) const override {
diff --git a/src/mongo/db/commands/conn_pool_sync.cpp b/src/mongo/db/commands/conn_pool_sync.cpp
index ecf135bb7e6..44893d621e6 100644
--- a/src/mongo/db/commands/conn_pool_sync.cpp
+++ b/src/mongo/db/commands/conn_pool_sync.cpp
@@ -62,8 +62,8 @@ public:
globalConnPool.flush();
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
} poolFlushCmd;
diff --git a/src/mongo/db/commands/connection_status.cpp b/src/mongo/db/commands/connection_status.cpp
index 80b4fdd9e2c..14e6413014f 100644
--- a/src/mongo/db/commands/connection_status.cpp
+++ b/src/mongo/db/commands/connection_status.cpp
@@ -41,8 +41,8 @@ using std::stringstream;
class CmdConnectionStatus : public BasicCommand {
public:
CmdConnectionStatus() : BasicCommand("connectionStatus") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp
index 99178166050..297ec8f1c10 100644
--- a/src/mongo/db/commands/copydb.cpp
+++ b/src/mongo/db/commands/copydb.cpp
@@ -95,8 +95,8 @@ public:
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp
index 6f675971ea0..59c21a4fcd2 100644
--- a/src/mongo/db/commands/copydb_start_commands.cpp
+++ b/src/mongo/db/commands/copydb_start_commands.cpp
@@ -78,10 +78,11 @@ public:
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index 129af8c89de..639d842e1db 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -63,12 +63,13 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- if (repl::getGlobalReplicationCoordinator()->getSettings().isSlave()) {
- // ok on --slave setups
- return Command::AllowedOnSecondary::kAlways;
- }
- return Command::AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ // ok on --slave setups
+ return repl::getGlobalReplicationCoordinator()->getSettings().isSlave();
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool maintenanceOk() const {
diff --git a/src/mongo/db/commands/cpuload.cpp b/src/mongo/db/commands/cpuload.cpp
index 587ee0af693..be297b83ed6 100644
--- a/src/mongo/db/commands/cpuload.cpp
+++ b/src/mongo/db/commands/cpuload.cpp
@@ -42,8 +42,8 @@ using std::stringstream;
class CPULoadCommand : public BasicCommand {
public:
CPULoadCommand() : BasicCommand("cpuload") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool isWriteCommandForConfigServer() const {
return false;
diff --git a/src/mongo/db/commands/cpuprofile.cpp b/src/mongo/db/commands/cpuprofile.cpp
index 396e396856d..51cc7d8a205 100644
--- a/src/mongo/db/commands/cpuprofile.cpp
+++ b/src/mongo/db/commands/cpuprofile.cpp
@@ -71,8 +71,8 @@ namespace {
class CpuProfilerCommand : public ErrmsgCommandDeprecated {
public:
CpuProfilerCommand(char const* name) : ErrmsgCommandDeprecated(name) {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
return true;
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index a38c935163c..036e8dc5148 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -216,9 +216,9 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
- }
+ virtual bool slaveOk() const {
+ return false;
+ } // TODO: this could be made true...
virtual Status checkAuthForCommand(Client* client,
const std::string& dbname,
diff --git a/src/mongo/db/commands/current_op_common.h b/src/mongo/db/commands/current_op_common.h
index 367fb7f0ba8..517d494d851 100644
--- a/src/mongo/db/commands/current_op_common.h
+++ b/src/mongo/db/commands/current_op_common.h
@@ -51,8 +51,8 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const final {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const final {
+ return true;
}
bool adminOnly() const final {
diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp
index 3cbc2abe362..15b6e6cd516 100644
--- a/src/mongo/db/commands/dbcheck.cpp
+++ b/src/mongo/db/commands/dbcheck.cpp
@@ -489,8 +489,8 @@ class DbCheckCmd : public BasicCommand {
public:
DbCheckCmd() : BasicCommand("dbCheck") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool adminOnly() const {
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 8f25ddcc13d..b46512cd7e2 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -147,8 +147,8 @@ public:
std::string help() const override {
return "drop (delete) this database";
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual void addRequiredPrivileges(const std::string& dbname,
@@ -210,8 +210,8 @@ public:
class CmdRepairDatabase : public ErrmsgCommandDeprecated {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool maintenanceMode() const {
return true;
@@ -295,8 +295,8 @@ public:
*/
class CmdProfile : public ErrmsgCommandDeprecated {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
std::string help() const override {
@@ -396,8 +396,8 @@ public:
class CmdDrop : public ErrmsgCommandDeprecated {
public:
CmdDrop() : ErrmsgCommandDeprecated("drop") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool adminOnly() const {
return false;
@@ -452,8 +452,8 @@ public:
class CmdCreate : public BasicCommand {
public:
CmdCreate() : BasicCommand("create") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool adminOnly() const {
return false;
@@ -570,8 +570,8 @@ class CmdFileMD5 : public BasicCommand {
public:
CmdFileMD5() : BasicCommand("filemd5") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
std::string help() const override {
@@ -747,8 +747,8 @@ class CmdDatasize : public ErrmsgCommandDeprecated {
public:
CmdDatasize() : ErrmsgCommandDeprecated("dataSize", "datasize") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -897,8 +897,8 @@ class CollectionStats : public ErrmsgCommandDeprecated {
public:
CollectionStats() : ErrmsgCommandDeprecated("collStats", "collstats") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -944,8 +944,8 @@ class CollectionModCommand : public BasicCommand {
public:
CollectionModCommand() : BasicCommand("collMod") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
@@ -978,8 +978,8 @@ class DBStats : public ErrmsgCommandDeprecated {
public:
DBStats() : ErrmsgCommandDeprecated("dbStats", "dbstats") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -1074,8 +1074,8 @@ public:
class CmdWhatsMyUri : public BasicCommand {
public:
CmdWhatsMyUri() : BasicCommand("whatsmyuri") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -1099,8 +1099,8 @@ class AvailableQueryOptions : public BasicCommand {
public:
AvailableQueryOptions() : BasicCommand("availableQueryOptions", "availablequeryoptions") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp
index e16a3068d12..1a006d41298 100644
--- a/src/mongo/db/commands/dbhash.cpp
+++ b/src/mongo/db/commands/dbhash.cpp
@@ -62,8 +62,8 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 50b05986912..b12a485d68e 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -75,8 +75,12 @@ class DistinctCommand : public BasicCommand {
public:
DistinctCommand() : BasicCommand("distinct") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
diff --git a/src/mongo/db/commands/do_txn_cmd.cpp b/src/mongo/db/commands/do_txn_cmd.cpp
index 806d282aa79..3193b5ba30d 100644
--- a/src/mongo/db/commands/do_txn_cmd.cpp
+++ b/src/mongo/db/commands/do_txn_cmd.cpp
@@ -131,8 +131,8 @@ class DoTxnCmd : public BasicCommand {
public:
DoTxnCmd() : BasicCommand("doTxn") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ bool slaveOk() const override {
+ return false;
}
bool supportsWriteConcern(const BSONObj& cmd) const override {
diff --git a/src/mongo/db/commands/driverHelpers.cpp b/src/mongo/db/commands/driverHelpers.cpp
index 9caef43f7b1..2f1e688aa15 100644
--- a/src/mongo/db/commands/driverHelpers.cpp
+++ b/src/mongo/db/commands/driverHelpers.cpp
@@ -59,9 +59,11 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
-
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
+ }
+ virtual bool slaveOverrideOk() const {
+ return true;
}
};
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 11cbed2f00c..8f311a94295 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -66,8 +66,8 @@ using std::vector;
/* "dropIndexes" is now the preferred form - "deleteIndexes" deprecated */
class CmdDropIndexes : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
@@ -96,9 +96,9 @@ public:
class CmdReIndex : public ErrmsgCommandDeprecated {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways; // can reindex on a secondary
- }
+ virtual bool slaveOk() const {
+ return true;
+ } // can reindex on a secondary
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
diff --git a/src/mongo/db/commands/end_sessions_command.cpp b/src/mongo/db/commands/end_sessions_command.cpp
index 9397d39f841..39383f8e58d 100644
--- a/src/mongo/db/commands/end_sessions_command.cpp
+++ b/src/mongo/db/commands/end_sessions_command.cpp
@@ -44,8 +44,8 @@ class EndSessionsCommand final : public BasicCommand {
public:
EndSessionsCommand() : BasicCommand("endSessions") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/eval.cpp b/src/mongo/db/commands/eval.cpp
index 0ae44555037..36153a54181 100644
--- a/src/mongo/db/commands/eval.cpp
+++ b/src/mongo/db/commands/eval.cpp
@@ -154,8 +154,8 @@ bool dbEval(OperationContext* opCtx,
class CmdEval : public ErrmsgCommandDeprecated {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
std::string help() const override {
diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp
index 0c5ffb15a06..08463e626df 100644
--- a/src/mongo/db/commands/explain_cmd.cpp
+++ b/src/mongo/db/commands/explain_cmd.cpp
@@ -28,7 +28,6 @@
#include "mongo/platform/basic.h"
-#include "mongo/db/command_can_run_here.h"
#include "mongo/db/commands.h"
#include "mongo/db/query/explain.h"
#include "mongo/db/repl/replication_coordinator_global.h"
@@ -63,8 +62,12 @@ public:
/**
* Running an explain on a secondary requires explicitly setting slaveOk.
*/
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool maintenanceOk() const {
@@ -146,7 +149,21 @@ public:
return CommandHelpers::appendCommandStatus(result, explainStatus);
}
- if (!commandCanRunHere(opCtx, dbname, commToExplain)) {
+ // Check whether the child command is allowed to run here. TODO: this logic is
+ // copied from Command::execCommand and should be abstracted. Until then, make
+ // sure to keep it up to date.
+ repl::ReplicationCoordinator* replCoord = repl::ReplicationCoordinator::get(opCtx);
+ bool iAmPrimary = replCoord->canAcceptWritesForDatabase_UNSAFE(opCtx, dbname);
+ bool commandCanRunOnSecondary = commToExplain->slaveOk();
+
+ bool commandIsOverriddenToRunOnSecondary = commToExplain->slaveOverrideOk() &&
+ ReadPreferenceSetting::get(opCtx).canRunOnSecondary();
+ bool iAmStandalone = !opCtx->writesAreReplicated();
+
+ const bool canRunHere = iAmPrimary || commandCanRunOnSecondary ||
+ commandIsOverriddenToRunOnSecondary || iAmStandalone;
+
+ if (!canRunHere) {
mongoutils::str::stream ss;
ss << "Explain's child command cannot run on this node. "
<< "Are you explaining a write command on a secondary?";
diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp
index 940bc33e6a4..efb705a7bff 100644
--- a/src/mongo/db/commands/fail_point_cmd.cpp
+++ b/src/mongo/db/commands/fail_point_cmd.cpp
@@ -68,10 +68,11 @@ class FaultInjectCmd : public ErrmsgCommandDeprecated {
public:
FaultInjectCmd() : ErrmsgCommandDeprecated("configureFailPoint") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index d5ebaf935c5..1e8193ce4c9 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -220,8 +220,8 @@ public:
"Output is in the \"value\" field\n";
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ bool slaveOk() const override {
+ return false;
}
bool supportsReadConcern(const std::string& dbName,
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 7139f52175f..1ce3f931e5b 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -69,8 +69,12 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ bool slaveOk() const override {
+ return false;
+ }
+
+ bool slaveOverrideOk() const override {
+ return true;
}
bool maintenanceOk() const override {
diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp
index 7c4a3799007..eb2b2d375c7 100644
--- a/src/mongo/db/commands/fsync.cpp
+++ b/src/mongo/db/commands/fsync.cpp
@@ -101,8 +101,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
return true;
@@ -273,8 +273,8 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp
index 7164b951586..28394239931 100644
--- a/src/mongo/db/commands/generic.cpp
+++ b/src/mongo/db/commands/generic.cpp
@@ -73,11 +73,9 @@ using std::vector;
class CmdBuildInfo : public BasicCommand {
public:
CmdBuildInfo() : BasicCommand("buildInfo", "buildinfo") {}
-
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
-
virtual bool adminOnly() const {
return false;
}
@@ -106,9 +104,8 @@ public:
class PingCommand : public BasicCommand {
public:
PingCommand() : BasicCommand("ping") {}
-
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
std::string help() const override {
return "a way to check that the server is alive. responds immediately even if server is "
@@ -141,8 +138,8 @@ public:
std::string help() const override {
return "return build level feature settings";
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -172,11 +169,11 @@ public:
class HostInfoCmd : public BasicCommand {
public:
HostInfoCmd() : BasicCommand("hostInfo") {}
-
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
@@ -224,8 +221,11 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
+ }
+ virtual bool adminOnly() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
@@ -255,8 +255,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
return false;
@@ -283,11 +283,11 @@ public:
for (const auto& c : commands) {
BSONObjBuilder temp(b.subobjStart(c->getName()));
temp.append("help", c->help());
- temp.append("slaveOk", c->secondaryAllowed() == Command::AllowedOnSecondary::kAlways);
+ temp.append("slaveOk", c->slaveOk());
temp.append("adminOnly", c->adminOnly());
// optionally indicates that the command can be forced to run on a slave/secondary
- if (c->secondaryAllowed() == Command::AllowedOnSecondary::kOptIn)
- temp.append("slaveOverrideOk", true);
+ if (c->slaveOverrideOk())
+ temp.append("slaveOverrideOk", c->slaveOverrideOk());
temp.done();
}
b.done();
@@ -297,37 +297,12 @@ public:
} listCommandsCmd;
-/* for testing purposes only */
-class CmdForceError : public BasicCommand {
-public:
- std::string help() const override {
- return "for testing purposes only. forces a user assertion exception";
- }
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
- }
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
- return false;
- }
- virtual void addRequiredPrivileges(const std::string& dbname,
- const BSONObj& cmdObj,
- std::vector<Privilege>* out) {} // No auth required
- CmdForceError() : BasicCommand("forceerror") {}
- bool run(OperationContext* opCtx,
- const string& dbnamne,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) {
- LastError::get(cc()).setLastError(10038, "forced error");
- return false;
- }
-} cmdForceError;
-
class GetLogCmd : public ErrmsgCommandDeprecated {
public:
GetLogCmd() : ErrmsgCommandDeprecated("getLog") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -397,8 +372,8 @@ class ClearLogCmd : public BasicCommand {
public:
ClearLogCmd() : BasicCommand("clearLog") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -458,8 +433,8 @@ public:
virtual bool adminOnly() const {
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp
index 7cf8a3b7e02..ac1d839100b 100644
--- a/src/mongo/db/commands/geo_near_cmd.cpp
+++ b/src/mongo/db/commands/geo_near_cmd.cpp
@@ -74,8 +74,11 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const {
+ return true;
+ }
+ bool slaveOverrideOk() const {
+ return true;
}
bool supportsReadConcern(const std::string& dbName,
const BSONObj& cmdObj,
diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp
index 0eb1a9939a0..3d2d6d414c1 100644
--- a/src/mongo/db/commands/get_last_error.cpp
+++ b/src/mongo/db/commands/get_last_error.cpp
@@ -60,8 +60,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
@@ -90,8 +90,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
@@ -313,8 +313,8 @@ public:
std::string help() const override {
return "check for errors since last reseterror commandcal";
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
bool requiresAuth() const override {
return false;
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index 16e5261dbde..594a2886d08 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -89,8 +89,8 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool maintenanceOk() const override {
diff --git a/src/mongo/db/commands/group_cmd.cpp b/src/mongo/db/commands/group_cmd.cpp
index 62f9ee7bbb3..85b93ec071a 100644
--- a/src/mongo/db/commands/group_cmd.cpp
+++ b/src/mongo/db/commands/group_cmd.cpp
@@ -71,8 +71,12 @@ private:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
bool supportsReadConcern(const std::string& dbName,
diff --git a/src/mongo/db/commands/hashcmd.cpp b/src/mongo/db/commands/hashcmd.cpp
index 021ccfd573a..f65fda66d84 100644
--- a/src/mongo/db/commands/hashcmd.cpp
+++ b/src/mongo/db/commands/hashcmd.cpp
@@ -56,8 +56,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
// No auth needed because it only works when enabled via command line.
virtual void addRequiredPrivileges(const std::string& dbname,
diff --git a/src/mongo/db/commands/haystack.cpp b/src/mongo/db/commands/haystack.cpp
index 61ccbbb00bc..18f3b1d1edc 100644
--- a/src/mongo/db/commands/haystack.cpp
+++ b/src/mongo/db/commands/haystack.cpp
@@ -68,8 +68,12 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const {
+ return true;
+ }
+
+ bool slaveOverrideOk() const {
+ return true;
}
bool supportsReadConcern(const std::string& dbName,
diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp
index 5bbae6c6de0..1eaeadcd656 100644
--- a/src/mongo/db/commands/index_filter_commands.cpp
+++ b/src/mongo/db/commands/index_filter_commands.cpp
@@ -129,8 +129,12 @@ bool IndexFilterCommand::supportsWriteConcern(const BSONObj& cmd) const {
return false;
}
-Command::AllowedOnSecondary IndexFilterCommand::secondaryAllowed() const {
- return AllowedOnSecondary::kOptIn;
+bool IndexFilterCommand::slaveOk() const {
+ return false;
+}
+
+bool IndexFilterCommand::slaveOverrideOk() const {
+ return true;
}
std::string IndexFilterCommand::help() const {
diff --git a/src/mongo/db/commands/index_filter_commands.h b/src/mongo/db/commands/index_filter_commands.h
index 72f758806c5..aaa785c0d6b 100644
--- a/src/mongo/db/commands/index_filter_commands.h
+++ b/src/mongo/db/commands/index_filter_commands.h
@@ -70,7 +70,9 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override;
- AllowedOnSecondary secondaryAllowed() const override;
+ virtual bool slaveOk() const;
+
+ virtual bool slaveOverrideOk() const;
std::string help() const override;
diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp
index e3c7d077aae..841dfde9e54 100644
--- a/src/mongo/db/commands/isself.cpp
+++ b/src/mongo/db/commands/isself.cpp
@@ -42,8 +42,8 @@ using std::stringstream;
class IsSelfCommand : public BasicCommand {
public:
IsSelfCommand() : BasicCommand("_isSelf") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
diff --git a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp
index 645c5e83c2c..708cb67d34b 100644
--- a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp
+++ b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp
@@ -57,8 +57,8 @@ class KillAllSessionsByPatternCommand final : public BasicCommand {
public:
KillAllSessionsByPatternCommand() : BasicCommand("killAllSessionsByPattern") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/kill_all_sessions_command.cpp b/src/mongo/db/commands/kill_all_sessions_command.cpp
index 4605a5f1964..86f0a629249 100644
--- a/src/mongo/db/commands/kill_all_sessions_command.cpp
+++ b/src/mongo/db/commands/kill_all_sessions_command.cpp
@@ -57,8 +57,8 @@ class KillAllSessionsCommand final : public BasicCommand {
public:
KillAllSessionsCommand() : BasicCommand("killAllSessions") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/kill_op.cpp b/src/mongo/db/commands/kill_op.cpp
index 8cc2754e919..7b07c87f7ba 100644
--- a/src/mongo/db/commands/kill_op.cpp
+++ b/src/mongo/db/commands/kill_op.cpp
@@ -55,8 +55,8 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const final {
+ return true;
}
bool adminOnly() const final {
diff --git a/src/mongo/db/commands/kill_sessions_command.cpp b/src/mongo/db/commands/kill_sessions_command.cpp
index 55f8dfc1a2d..0be33339f25 100644
--- a/src/mongo/db/commands/kill_sessions_command.cpp
+++ b/src/mongo/db/commands/kill_sessions_command.cpp
@@ -84,8 +84,8 @@ class KillSessionsCommand final : public BasicCommand {
public:
KillSessionsCommand() : BasicCommand("killSessions") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/killcursors_common.h b/src/mongo/db/commands/killcursors_common.h
index 90541adc709..6991a4a0da7 100644
--- a/src/mongo/db/commands/killcursors_common.h
+++ b/src/mongo/db/commands/killcursors_common.h
@@ -45,8 +45,8 @@ public:
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const final {
+ return true;
}
bool maintenanceOk() const final {
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index b92c59034ba..b21c0f959a1 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -197,8 +197,11 @@ BSONObj buildCollectionBson(OperationContext* opCtx,
class CmdListCollections : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool adminOnly() const {
return false;
diff --git a/src/mongo/db/commands/list_databases.cpp b/src/mongo/db/commands/list_databases.cpp
index 99bc8166021..f91cb10f680 100644
--- a/src/mongo/db/commands/list_databases.cpp
+++ b/src/mongo/db/commands/list_databases.cpp
@@ -57,8 +57,11 @@ intmax_t dbSize(const string& database);
class CmdListDatabases : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const final {
- return AllowedOnSecondary::kOptIn;
+ bool slaveOk() const final {
+ return false;
+ }
+ bool slaveOverrideOk() const final {
+ return true;
}
bool adminOnly() const final {
return true;
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp
index cef7130a20c..5c23ea9f1c6 100644
--- a/src/mongo/db/commands/list_indexes.cpp
+++ b/src/mongo/db/commands/list_indexes.cpp
@@ -76,8 +76,11 @@ namespace {
*/
class CmdListIndexes : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool adminOnly() const {
return false;
diff --git a/src/mongo/db/commands/lock_info.cpp b/src/mongo/db/commands/lock_info.cpp
index 3e16e220e39..6bd6aeb3258 100644
--- a/src/mongo/db/commands/lock_info.cpp
+++ b/src/mongo/db/commands/lock_info.cpp
@@ -49,8 +49,12 @@ using std::stringstream;
*/
class CmdLockInfo : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool adminOnly() const {
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index ce7d144bfcc..ef9043fd78a 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -1351,12 +1351,13 @@ class MapReduceCommand : public ErrmsgCommandDeprecated {
public:
MapReduceCommand() : ErrmsgCommandDeprecated("mapReduce", "mapreduce") {}
- AllowedOnSecondary secondaryAllowed() const override {
- if (repl::getGlobalReplicationCoordinator()->getReplicationMode() !=
- repl::ReplicationCoordinator::modeReplSet) {
- return AllowedOnSecondary::kAlways;
- }
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return repl::getGlobalReplicationCoordinator()->getReplicationMode() !=
+ repl::ReplicationCoordinator::modeReplSet;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
std::size_t reserveBytesForReply() const override {
@@ -1688,15 +1689,13 @@ public:
return "internal";
}
MapReduceFinishCommand() : BasicCommand("mapreduce.shardedfinish") {}
-
- AllowedOnSecondary secondaryAllowed() const override {
- if (repl::getGlobalReplicationCoordinator()->getReplicationMode() !=
- repl::ReplicationCoordinator::modeReplSet) {
- return AllowedOnSecondary::kAlways;
- }
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return repl::getGlobalReplicationCoordinator()->getReplicationMode() !=
+ repl::ReplicationCoordinator::modeReplSet;
+ }
+ virtual bool slaveOverrideOk() const {
+ return true;
}
-
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
}
diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp
index 2f1d06b79b5..9b26b979ba6 100644
--- a/src/mongo/db/commands/oplog_note.cpp
+++ b/src/mongo/db/commands/oplog_note.cpp
@@ -87,8 +87,8 @@ class AppendOplogNoteCmd : public BasicCommand {
public:
AppendOplogNoteCmd() : BasicCommand("appendOplogNote") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool adminOnly() const {
diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp
index c9f36a820e4..783e74be716 100644
--- a/src/mongo/db/commands/parallel_collection_scan.cpp
+++ b/src/mongo/db/commands/parallel_collection_scan.cpp
@@ -62,8 +62,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
bool supportsReadConcern(const std::string& dbName,
diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp
index 391a1ffded8..7e03b90985b 100644
--- a/src/mongo/db/commands/parameters.cpp
+++ b/src/mongo/db/commands/parameters.cpp
@@ -67,8 +67,8 @@ void appendParameterNames(std::string* help) {
class CmdGet : public ErrmsgCommandDeprecated {
public:
CmdGet() : ErrmsgCommandDeprecated("getParameter") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
return true;
@@ -118,8 +118,8 @@ public:
class CmdSet : public ErrmsgCommandDeprecated {
public:
CmdSet() : ErrmsgCommandDeprecated("setParameter") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
return true;
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index ae607f2713f..8ec12102c35 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -57,8 +57,12 @@ public:
return Pipeline::aggSupportsWriteConcern(cmd);
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ bool slaveOk() const override {
+ return false;
+ }
+
+ bool slaveOverrideOk() const override {
+ return true;
}
bool supportsReadConcern(const std::string& dbName,
diff --git a/src/mongo/db/commands/plan_cache_commands.cpp b/src/mongo/db/commands/plan_cache_commands.cpp
index a76100a90c7..0cd3593f5c1 100644
--- a/src/mongo/db/commands/plan_cache_commands.cpp
+++ b/src/mongo/db/commands/plan_cache_commands.cpp
@@ -124,8 +124,12 @@ bool PlanCacheCommand::supportsWriteConcern(const BSONObj& cmd) const {
return false;
}
-Command::AllowedOnSecondary PlanCacheCommand::secondaryAllowed() const {
- return AllowedOnSecondary::kOptIn;
+bool PlanCacheCommand::slaveOk() const {
+ return false;
+}
+
+bool PlanCacheCommand::slaveOverrideOk() const {
+ return true;
}
std::string PlanCacheCommand::help() const {
diff --git a/src/mongo/db/commands/plan_cache_commands.h b/src/mongo/db/commands/plan_cache_commands.h
index c883a189820..0b0a680b2da 100644
--- a/src/mongo/db/commands/plan_cache_commands.h
+++ b/src/mongo/db/commands/plan_cache_commands.h
@@ -64,7 +64,9 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override;
- AllowedOnSecondary secondaryAllowed() const override;
+ virtual bool slaveOk() const;
+
+ virtual bool slaveOverrideOk() const;
std::string help() const override;
diff --git a/src/mongo/db/commands/reap_logical_session_cache_now.cpp b/src/mongo/db/commands/reap_logical_session_cache_now.cpp
index f04ee086359..879952791fc 100644
--- a/src/mongo/db/commands/reap_logical_session_cache_now.cpp
+++ b/src/mongo/db/commands/reap_logical_session_cache_now.cpp
@@ -44,8 +44,8 @@ class ReapLogicalSessionCacheNowCommand final : public BasicCommand {
public:
ReapLogicalSessionCacheNowCommand() : BasicCommand("reapLogicalSessionCacheNow") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
diff --git a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp
index ff3e018eede..5dcbe213eaa 100644
--- a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp
+++ b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp
@@ -45,8 +45,8 @@ class RefreshLogicalSessionCacheNowCommand final : public BasicCommand {
public:
RefreshLogicalSessionCacheNowCommand() : BasicCommand("refreshLogicalSessionCacheNow") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
diff --git a/src/mongo/db/commands/refresh_sessions_command.cpp b/src/mongo/db/commands/refresh_sessions_command.cpp
index 0570821ca1e..4db76567261 100644
--- a/src/mongo/db/commands/refresh_sessions_command.cpp
+++ b/src/mongo/db/commands/refresh_sessions_command.cpp
@@ -46,8 +46,8 @@ class RefreshSessionsCommand final : public BasicCommand {
public:
RefreshSessionsCommand() : BasicCommand("refreshSessions") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/refresh_sessions_command_internal.cpp b/src/mongo/db/commands/refresh_sessions_command_internal.cpp
index fa52de2caec..1cfbf7deeb0 100644
--- a/src/mongo/db/commands/refresh_sessions_command_internal.cpp
+++ b/src/mongo/db/commands/refresh_sessions_command_internal.cpp
@@ -46,8 +46,8 @@ class RefreshSessionsCommandInternal final : public BasicCommand {
public:
RefreshSessionsCommandInternal() : BasicCommand("refreshSessionsInternal") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp
index 01cba8c386a..144ecbf847e 100644
--- a/src/mongo/db/commands/rename_collection_cmd.cpp
+++ b/src/mongo/db/commands/rename_collection_cmd.cpp
@@ -62,8 +62,8 @@ public:
virtual bool adminOnly() const {
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
diff --git a/src/mongo/db/commands/repair_cursor.cpp b/src/mongo/db/commands/repair_cursor.cpp
index 12c4cfa3528..51567abbabc 100644
--- a/src/mongo/db/commands/repair_cursor.cpp
+++ b/src/mongo/db/commands/repair_cursor.cpp
@@ -52,8 +52,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual Status checkAuthForCommand(Client* client,
diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp
index ef853e9bb17..4373c9c9dd5 100644
--- a/src/mongo/db/commands/resize_oplog.cpp
+++ b/src/mongo/db/commands/resize_oplog.cpp
@@ -54,8 +54,8 @@ class CmdReplSetResizeOplog : public BasicCommand {
public:
CmdReplSetResizeOplog() : BasicCommand("replSetResizeOplog") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const final {
+ return true;
}
bool adminOnly() const final {
diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp
index 98aefce2f62..a4b63e778f2 100644
--- a/src/mongo/db/commands/server_status.cpp
+++ b/src/mongo/db/commands/server_status.cpp
@@ -72,8 +72,8 @@ public:
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool allowsAfterClusterTime(const BSONObj& cmdObj) const override {
return false;
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index b4f58018eaa..31e28b6a5b5 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -69,8 +69,8 @@ public:
SetFeatureCompatibilityVersionCommand()
: BasicCommand(FeatureCompatibilityVersion::kCommandName) {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool adminOnly() const {
diff --git a/src/mongo/db/commands/shutdown.h b/src/mongo/db/commands/shutdown.h
index e89aa301261..655d25b367f 100644
--- a/src/mongo/db/commands/shutdown.h
+++ b/src/mongo/db/commands/shutdown.h
@@ -48,8 +48,8 @@ public:
virtual bool localHostOnlyIfNoAuth() {
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
diff --git a/src/mongo/db/commands/snapshot_management.cpp b/src/mongo/db/commands/snapshot_management.cpp
index 096cdbf2582..3661447d224 100644
--- a/src/mongo/db/commands/snapshot_management.cpp
+++ b/src/mongo/db/commands/snapshot_management.cpp
@@ -44,8 +44,8 @@ class CmdMakeSnapshot final : public BasicCommand {
public:
CmdMakeSnapshot() : BasicCommand("makeSnapshot") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
@@ -92,8 +92,8 @@ class CmdSetCommittedSnapshot final : public BasicCommand {
public:
CmdSetCommittedSnapshot() : BasicCommand("setCommittedSnapshot") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
diff --git a/src/mongo/db/commands/start_session_command.cpp b/src/mongo/db/commands/start_session_command.cpp
index a577cc01cb7..b621ca02237 100644
--- a/src/mongo/db/commands/start_session_command.cpp
+++ b/src/mongo/db/commands/start_session_command.cpp
@@ -51,8 +51,8 @@ class StartSessionCommand final : public BasicCommand {
public:
StartSessionCommand() : BasicCommand("startSession") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ bool slaveOk() const override {
+ return true;
}
bool adminOnly() const override {
return false;
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index c7c7c5db1a4..1615117783e 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -62,8 +62,8 @@ public:
virtual bool adminOnly() const {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
@@ -118,8 +118,8 @@ public:
return true;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
std::string help() const override {
@@ -201,8 +201,8 @@ public:
class CapTrunc : public BasicCommand {
public:
CapTrunc() : BasicCommand("captrunc") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
@@ -276,8 +276,8 @@ public:
class EmptyCapped : public BasicCommand {
public:
EmptyCapped() : BasicCommand("emptycapped") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp
index d7691005285..241c44e5702 100644
--- a/src/mongo/db/commands/top_command.cpp
+++ b/src/mongo/db/commands/top_command.cpp
@@ -46,8 +46,8 @@ class TopCommand : public BasicCommand {
public:
TopCommand() : BasicCommand("top") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
return true;
diff --git a/src/mongo/db/commands/touch.cpp b/src/mongo/db/commands/touch.cpp
index 2423c3ae6bd..d9c2651f34d 100644
--- a/src/mongo/db/commands/touch.cpp
+++ b/src/mongo/db/commands/touch.cpp
@@ -61,8 +61,8 @@ public:
virtual bool adminOnly() const {
return false;
}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool maintenanceMode() const {
return true;
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp
index 7aafdce777b..9ccf077f479 100644
--- a/src/mongo/db/commands/user_management_commands.cpp
+++ b/src/mongo/db/commands/user_management_commands.cpp
@@ -611,8 +611,8 @@ class CmdCreateUser : public BasicCommand {
public:
CmdCreateUser() : BasicCommand("createUser") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -758,8 +758,8 @@ class CmdUpdateUser : public BasicCommand {
public:
CmdUpdateUser() : BasicCommand("updateUser") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -892,8 +892,8 @@ class CmdDropUser : public BasicCommand {
public:
CmdDropUser() : BasicCommand("dropUser") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -959,8 +959,8 @@ class CmdDropAllUsersFromDatabase : public BasicCommand {
public:
CmdDropAllUsersFromDatabase() : BasicCommand("dropAllUsersFromDatabase") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1015,8 +1015,8 @@ class CmdGrantRolesToUser : public BasicCommand {
public:
CmdGrantRolesToUser() : BasicCommand("grantRolesToUser") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1087,8 +1087,8 @@ class CmdRevokeRolesFromUser : public BasicCommand {
public:
CmdRevokeRolesFromUser() : BasicCommand("revokeRolesFromUser") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1157,8 +1157,12 @@ public:
class CmdUsersInfo : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1281,8 +1285,8 @@ class CmdCreateRole : public BasicCommand {
public:
CmdCreateRole() : BasicCommand("createRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1402,8 +1406,8 @@ class CmdUpdateRole : public BasicCommand {
public:
CmdUpdateRole() : BasicCommand("updateRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1519,8 +1523,8 @@ class CmdGrantPrivilegesToRole : public BasicCommand {
public:
CmdGrantPrivilegesToRole() : BasicCommand("grantPrivilegesToRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1629,8 +1633,8 @@ class CmdRevokePrivilegesFromRole : public BasicCommand {
public:
CmdRevokePrivilegesFromRole() : BasicCommand("revokePrivilegesFromRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1741,8 +1745,8 @@ class CmdGrantRolesToRole : public BasicCommand {
public:
CmdGrantRolesToRole() : BasicCommand("grantRolesToRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1830,8 +1834,8 @@ class CmdRevokeRolesFromRole : public BasicCommand {
public:
CmdRevokeRolesFromRole() : BasicCommand("revokeRolesFromRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -1914,8 +1918,8 @@ class CmdDropRole : public BasicCommand {
public:
CmdDropRole() : BasicCommand("dropRole") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -2056,8 +2060,8 @@ class CmdDropAllRolesFromDatabase : public BasicCommand {
public:
CmdDropAllRolesFromDatabase() : BasicCommand("dropAllRolesFromDatabase") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -2187,8 +2191,12 @@ public:
class CmdRolesInfo : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kOptIn;
+ virtual bool slaveOk() const {
+ return false;
+ }
+
+ virtual bool slaveOverrideOk() const {
+ return true;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
@@ -2272,8 +2280,8 @@ public:
class CmdInvalidateUserCache : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
@@ -2309,8 +2317,8 @@ public:
class CmdGetCacheGeneration : public BasicCommand {
public:
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
virtual bool adminOnly() const {
@@ -2358,8 +2366,8 @@ class CmdMergeAuthzCollections : public BasicCommand {
public:
CmdMergeAuthzCollections() : BasicCommand("_mergeAuthzCollections") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kNever;
+ virtual bool slaveOk() const {
+ return false;
}
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp
index 1ef643d87cf..f3d04650286 100644
--- a/src/mongo/db/commands/validate.cpp
+++ b/src/mongo/db/commands/validate.cpp
@@ -67,8 +67,8 @@ class ValidateCmd : public BasicCommand {
public:
ValidateCmd() : BasicCommand("validate") {}
- AllowedOnSecondary secondaryAllowed() const override {
- return AllowedOnSecondary::kAlways;
+ virtual bool slaveOk() const {
+ return true;
}
std::string help() const override {
diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp
index ac0a73dee89..922c5a57652 100644
--- a/src/mongo/db/commands/write_commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands/write_commands.cpp
@@ -198,8 +198,8 @@ class WriteCommand : public Command {
public:
explicit WriteCommand(StringData name) : Command(name) {}
- AllowedOnSecondary secondaryAllowed() const final {
- return AllowedOnSecondary::kNever;
+ bool slaveOk() const final {
+ return false;
}
bool shouldAffectCommandCounter() const final {