summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorPavithra Vetriselvan <pavithra.vetriselvan@mongodb.com>2019-09-24 18:43:38 +0000
committerevergreen <evergreen@mongodb.com>2019-09-24 18:43:38 +0000
commit1a3936b3ee365de5dde80e440c01fa6e868a1a54 (patch)
tree379083e43d6716bc4e7ce42dc2104e936f46ec7b /src/mongo/db/catalog
parent108425fdd063a0c7dae50b2d48d3dadea35a0557 (diff)
downloadmongo-1a3936b3ee365de5dde80e440c01fa6e868a1a54.tar.gz
SERVER-42312 disallow validate cmd during rollback and recovering states
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/collection_validation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp
index cbdad01bd3a..d2a76a9750d 100644
--- a/src/mongo/db/catalog/collection_validation.cpp
+++ b/src/mongo/db/catalog/collection_validation.cpp
@@ -397,6 +397,12 @@ Status validate(OperationContext* opCtx,
// constructor fail the cmd, as opposed to returning OK with valid:false.
ValidateState validateState(opCtx, nss, background, fullValidate);
+ const auto replCoord = repl::ReplicationCoordinator::get(opCtx);
+ // Check whether we are allowed to read from this node after acquiring our locks. If we are
+ // in a state where we cannot read, we should not run validate.
+ uassertStatusOK(replCoord->checkCanServeReadsFor(
+ opCtx, nss, ReadPreferenceSetting::get(opCtx).canRunOnSecondary()));
+
try {
std::map<std::string, int64_t> numIndexKeysPerIndex;
ValidateResultsMap indexNsResultsMap;