diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2020-05-21 13:29:13 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-21 17:55:43 +0000 |
commit | 3e9506132052647bdfb163f4acf8eed34db7d99c (patch) | |
tree | eeacc584fd323c2dd2aa701bed31a68cbb1356f9 /src/mongo/db/commands/validate.cpp | |
parent | d05251d26bcc7f52a7a3f7caaebf4e9682d60ecd (diff) | |
download | mongo-3e9506132052647bdfb163f4acf8eed34db7d99c.tar.gz |
SERVER-44650 Add new test mode enforeFastCount to foreground validate
Diffstat (limited to 'src/mongo/db/commands/validate.cpp')
-rw-r--r-- | src/mongo/db/commands/validate.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index badb47a4852..50c22f6b87c 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -140,12 +140,20 @@ public: << " and { full: true } is not supported."); } + const bool enforceFastCount = cmdObj["enforceFastCount"].trueValue(); + if (background && enforceFastCount) { + uasserted(ErrorCodes::CommandNotSupported, + str::stream() << "Running the validate command with both { background: true }" + << " and { enforceFastCount: true } is not supported."); + } + if (!serverGlobalParams.quiet.load()) { LOGV2(20514, "CMD: validate", "namespace"_attr = nss, "background"_attr = background, - "full"_attr = fullValidate); + "full"_attr = fullValidate, + "enforceFastCount"_attr = enforceFastCount); } // Only one validation per collection can be in progress, the rest wait. @@ -172,12 +180,17 @@ public: _validationNotifier.notify_all(); }); - auto options = (fullValidate) ? CollectionValidation::ValidateOptions::kFullValidation - : CollectionValidation::ValidateOptions::kNoFullValidation; - + auto mode = [&] { + if (background) + return CollectionValidation::ValidateMode::kBackground; + if (enforceFastCount) + return CollectionValidation::ValidateMode::kForegroundFullEnforceFastCount; + if (fullValidate) + return CollectionValidation::ValidateMode::kForegroundFull; + return CollectionValidation::ValidateMode::kForeground; + }(); ValidateResults validateResults; - Status status = CollectionValidation::validate( - opCtx, nss, options, background, &validateResults, &result); + Status status = CollectionValidation::validate(opCtx, nss, mode, &validateResults, &result); if (!status.isOK()) { return CommandHelpers::appendCommandStatusNoThrow(result, status); } |