From 560b266f41b1507ddb09cf6dfd61f26ca60b89b7 Mon Sep 17 00:00:00 2001 From: Gregory Wlodarek Date: Fri, 24 Apr 2020 12:40:52 -0400 Subject: SERVER-47754 Allow background validation to run on storage engines that do not support checkpoints --- src/mongo/db/commands/validate.cpp | 27 +++++++++++++-------------- src/mongo/db/storage/storage_init.cpp | 1 - 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index f9f6f2811c0..c60c32076cc 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -122,16 +122,15 @@ public: } const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj)); - - const bool background = cmdObj["background"].trueValue(); - - // Background validation requires the storage engine to support checkpoints because it - // performs the validation on a checkpoint using checkpoint cursors. - if (background && !opCtx->getServiceContext()->getStorageEngine()->supportsCheckpoints()) { - uasserted(ErrorCodes::CommandNotSupported, - str::stream() << "Running validate on collection " << nss - << " with { background: true } is not supported on the " - << storageGlobalParams.engine << " storage engine"); + bool background = cmdObj["background"].trueValue(); + + // Background validation is not supported on the ephemeralForTest storage engine due to its + // lack of support for timestamps. Switch the mode to foreground validation instead. + if (background && storageGlobalParams.engine == "ephemeralForTest") { + LOGV2(4775400, + "ephemeralForTest does not support background validation, switching to " + "foreground validation."); + background = false; } const bool fullValidate = cmdObj["full"].trueValue(); @@ -143,10 +142,10 @@ public: if (!serverGlobalParams.quiet.load()) { LOGV2(20514, - "CMD: validate {nss_ns}{background_background_true}{fullValidate_full_true}", - "nss_ns"_attr = nss.ns(), - "background_background_true"_attr = (background ? ", background:true" : ""), - "fullValidate_full_true"_attr = (fullValidate ? ", full:true" : "")); + "CMD: validate", + "namespace"_attr = nss, + "background"_attr = background, + "full"_attr = fullValidate); } // Only one validation per collection can be in progress, the rest wait. diff --git a/src/mongo/db/storage/storage_init.cpp b/src/mongo/db/storage/storage_init.cpp index 79da6ba81a8..b1e5b391890 100644 --- a/src/mongo/db/storage/storage_init.cpp +++ b/src/mongo/db/storage/storage_init.cpp @@ -68,7 +68,6 @@ public: << static_cast(engine->getDropPendingIdents().size()) << "supportsTwoPhaseIndexBuild" << engine->supportsTwoPhaseIndexBuild() << "supportsSnapshotReadConcern" << engine->supportsReadConcernSnapshot() - << "supportsCheckpointCursors" << engine->supportsCheckpoints() << "readOnly" << storageGlobalParams.readOnly << "persistent" << !engine->isEphemeral() << "backupCursorOpen" << backupCursorHooks->isBackupCursorOpen()); -- cgit v1.2.1