diff options
author | Pavithra Vetriselvan <pavithra.vetriselvan@mongodb.com> | 2019-09-24 18:43:38 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-24 18:43:38 +0000 |
commit | 1a3936b3ee365de5dde80e440c01fa6e868a1a54 (patch) | |
tree | 379083e43d6716bc4e7ce42dc2104e936f46ec7b /src/mongo/db/catalog | |
parent | 108425fdd063a0c7dae50b2d48d3dadea35a0557 (diff) | |
download | mongo-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.cpp | 6 |
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; |