diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/repl/dbcheck.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/repl/dbcheck.cpp')
| -rw-r--r-- | src/mongo/db/repl/dbcheck.cpp | 103 |
1 files changed, 8 insertions, 95 deletions
diff --git a/src/mongo/db/repl/dbcheck.cpp b/src/mongo/db/repl/dbcheck.cpp index cc140a71817..6fb94689544 100644 --- a/src/mongo/db/repl/dbcheck.cpp +++ b/src/mongo/db/repl/dbcheck.cpp @@ -27,16 +27,15 @@ * it in the license file. */ -#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kCommand - #include "mongo/platform/basic.h" #include "mongo/bson/simple_bsonelement_comparator.h" #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/catalog/database.h" #include "mongo/db/catalog/database_holder.h" -#include "mongo/db/catalog/health_log_interface.h" +#include "mongo/db/catalog/health_log.h" #include "mongo/db/catalog/index_catalog.h" +#include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/db_raii.h" #include "mongo/db/operation_context.h" #include "mongo/db/query/internal_plans.h" @@ -45,13 +44,10 @@ #include "mongo/db/repl/dbcheck_gen.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/optime.h" -#include "mongo/db/repl/repl_server_parameters_gen.h" -#include "mongo/logv2/log.h" namespace mongo { MONGO_FAIL_POINT_DEFINE(SleepDbCheckInBatch); -MONGO_FAIL_POINT_DEFINE(hangAfterGeneratingHashForExtraIndexKeysCheck); namespace { @@ -386,7 +382,7 @@ Status dbCheckBatchOnSecondary(OperationContext* opCtx, "dbCheck failed", OplogEntriesEnum::Batch, BSON("success" << false << "info" << msg)); - HealthLogInterface::get(opCtx)->log(*logEntry); + HealthLog::get(opCtx).log(*logEntry); return Status::OK(); } @@ -412,21 +408,13 @@ Status dbCheckBatchOnSecondary(OperationContext* opCtx, (batchesProcessed % gDbCheckHealthLogEveryNBatches.load() == 0)) { // On debug builds, health-log every batch result; on release builds, health-log // every N batches. - HealthLogInterface::get(opCtx)->log(*logEntry); - } - - if (MONGO_unlikely(hangAfterGeneratingHashForExtraIndexKeysCheck.shouldFail())) { - LOGV2_DEBUG(3083200, - 3, - "Hanging due to hangAfterGeneratingHashForExtraIndexKeysCheck failpoint"); - // hangAfterGeneratingHashForExtraIndexKeysCheck.pauseWhileSet(opCtx); - opCtx->sleepFor(Milliseconds(1000)); + HealthLog::get(opCtx).log(*logEntry); } } catch (const DBException& exception) { // In case of an error, report it to the health log, auto logEntry = dbCheckErrorHealthLogEntry( entry.getNss(), msg, OplogEntriesEnum::Batch, exception.toStatus(), entry.toBSON()); - HealthLogInterface::get(opCtx)->log(*logEntry); + HealthLog::get(opCtx).log(*logEntry); return Status::OK(); } return Status::OK(); @@ -450,79 +438,10 @@ Status dbCheckOplogCommand(OperationContext* opCtx, auto type = OplogEntries_parse(IDLParserErrorContext("type"), cmd.getStringField("type")); IDLParserErrorContext ctx("o"); - auto skipDbCheck = mode != OplogApplication::Mode::kSecondary; - std::string oplogApplicationMode; - if (mode == OplogApplication::Mode::kInitialSync) { - oplogApplicationMode = "initial sync"; - } else if (mode == OplogApplication::Mode::kUnstableRecovering) { - oplogApplicationMode = "unstable recovering"; - } else if (mode == OplogApplication::Mode::kStableRecovering) { - oplogApplicationMode = "stable recovering"; - } else if (mode == OplogApplication::Mode::kApplyOpsCmd) { - oplogApplicationMode = "applyOps"; - } else { - oplogApplicationMode = "secondary"; - } switch (type) { case OplogEntriesEnum::Batch: { auto invocation = DbCheckOplogBatch::parse(ctx, cmd); - - /* - // TODO SERVER-78399: Clean up handling minKey/maxKey once feature flag is removed. - // If the dbcheck oplog entry doesn't contain batchStart, convert minKey to a BSONObj to - // be used as batchStart. - BSONObj batchStart, batchEnd, batchId; - if (!invocation.getBatchStart()) { - batchStart = BSON("_id" << invocation.getMinKey().elem()); - } else { - batchStart = invocation.getBatchStart().get(); - } - if (!invocation.getBatchEnd()) { - batchEnd = BSON("_id" << invocation.getMaxKey().elem()); - } else { - batchEnd = invocation.getBatchEnd().get(); - } - */ - - if (!skipDbCheck && !repl::skipApplyingDbCheckBatchOnSecondary.load()) { - return dbCheckBatchOnSecondary(opCtx, opTime, invocation); - } - - // TODO SERVER-89921: Uncomment once the relevant tickets are backported. - /* - if (invocation.getBatchId()) { - batchId = invocation.getBatchId().get().toBSON(); - } - - BSONObjBuilder data; - data.append("batchStart", batchStart); - data.append("batchEnd", batchEnd); - - if (!batchId.isEmpty()) { - data.append("batchId", batchId); - } - */ - - auto warningMsg = "cannot execute dbcheck due to ongoing " + oplogApplicationMode; - if (repl::skipApplyingDbCheckBatchOnSecondary.load()) { - warningMsg = - "skipping applying dbcheck batch because the " - "'skipApplyingDbCheckBatchOnSecondary' parameter is on"; - } - - LOGV2_DEBUG(8888500, 3, "skipping applying dbcheck batch", "reason"_attr = warningMsg); - // TODO SERVER-89921: Uncomment these logging attributes once the relevant tickets are - // backported. - //"batchStart"_attr = batchStart, - //"batchEnd"_attr = batchEnd, - //"batchId"_attr = batchId); - - auto healthLogEntry = mongo::dbCheckHealthLogEntry( - invocation.getNss(), SeverityEnum::Warning, warningMsg, type, boost::none /*data*/); - - HealthLogInterface::get(Client::getCurrent()->getServiceContext()) - ->log(*healthLogEntry); - return Status::OK(); + return dbCheckBatchOnSecondary(opCtx, opTime, invocation); } case OplogEntriesEnum::Collection: { // TODO SERVER-61963. @@ -532,15 +451,9 @@ Status dbCheckOplogCommand(OperationContext* opCtx, // fallthrough case OplogEntriesEnum::Stop: const auto healthLogEntry = mongo::dbCheckHealthLogEntry( - boost::none /*nss*/, - skipDbCheck ? SeverityEnum::Warning : SeverityEnum::Info, - skipDbCheck ? "cannot execute dbcheck due to ongoing " + oplogApplicationMode : "", - type, - boost::none /*data*/ + boost::none /*nss*/, SeverityEnum::Info, "", type, boost::none /*data*/ ); - // TODO: need to change this - HealthLogInterface::get(Client::getCurrent()->getServiceContext()) - ->log(*healthLogEntry); + HealthLog::get(Client::getCurrent()->getServiceContext()).log(*healthLogEntry); return Status::OK(); } |
