diff options
Diffstat (limited to 'src/mongo/db/catalog/collection_validation.cpp')
-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; |