summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/dbcheck.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/commands/dbcheck.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (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/commands/dbcheck.cpp')
-rw-r--r--src/mongo/db/commands/dbcheck.cpp52
1 files changed, 13 insertions, 39 deletions
diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp
index 5d4579691dd..c26b09d8831 100644
--- a/src/mongo/db/commands/dbcheck.cpp
+++ b/src/mongo/db/commands/dbcheck.cpp
@@ -36,10 +36,10 @@
#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/collection_catalog_helper.h"
#include "mongo/db/catalog/database.h"
-#include "mongo/db/catalog/health_log_interface.h"
+#include "mongo/db/catalog/health_log.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/test_commands_enabled.h"
-#include "mongo/db/concurrency/exception_util.h"
+#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context.h"
@@ -52,10 +52,6 @@
#include "mongo/logv2/log.h"
-MONGO_FAIL_POINT_DEFINE(sleepAfterExtraIndexKeysHashing);
-MONGO_FAIL_POINT_DEFINE(hangBeforeProcessingDbCheckRun);
-MONGO_FAIL_POINT_DEFINE(hangBeforeAddingDBCheckBatchToOplog);
-
namespace mongo {
namespace {
@@ -97,7 +93,7 @@ public:
OplogEntriesEnum::Start,
boost::none /*data*/
);
- HealthLogInterface::get(_opCtx->getServiceContext())->log(*healthLogEntry);
+ HealthLog::get(_opCtx->getServiceContext()).log(*healthLogEntry);
DbCheckOplogStartStop oplogEntry;
const auto nss = NamespaceString("admin.$cmd");
@@ -123,7 +119,7 @@ public:
OplogEntriesEnum::Stop,
boost::none /*data*/
);
- HealthLogInterface::get(_opCtx->getServiceContext())->log(*healthLogEntry);
+ HealthLog::get(_opCtx->getServiceContext()).log(*healthLogEntry);
} catch (const DBException&) {
LOGV2(6202201, "Could not log stop event");
}
@@ -290,18 +286,13 @@ protected:
DbCheckStartAndStopLogger startStop(opCtx);
- if (MONGO_unlikely(hangBeforeProcessingDbCheckRun.shouldFail())) {
- LOGV2(7949000, "Hanging dbcheck due to failpoint 'hangBeforeProcessingDbCheckRun'");
- hangBeforeProcessingDbCheckRun.pauseWhileSet();
- }
-
for (const auto& coll : *_run) {
try {
_doCollection(opCtx, coll);
} catch (const DBException& e) {
auto logEntry = dbCheckErrorHealthLogEntry(
coll.nss, "dbCheck failed", OplogEntriesEnum::Batch, e.toStatus());
- HealthLogInterface::get(Client::getCurrent()->getServiceContext())->log(*logEntry);
+ HealthLog::get(Client::getCurrent()->getServiceContext()).log(*logEntry);
return;
}
@@ -332,7 +323,7 @@ private:
"abandoning dbCheck batch because collection no longer exists",
OplogEntriesEnum::Batch,
Status(ErrorCodes::NamespaceNotFound, "collection not found"));
- HealthLogInterface::get(Client::getCurrent()->getServiceContext())->log(*entry);
+ HealthLog::get(Client::getCurrent()->getServiceContext()).log(*entry);
return;
}
}
@@ -410,7 +401,7 @@ private:
OplogEntriesEnum::Batch,
result.getStatus());
}
- HealthLogInterface::get(opCtx)->log(*entry);
+ HealthLog::get(opCtx).log(*entry);
if (retryable) {
continue;
}
@@ -433,28 +424,17 @@ private:
(_batchesProcessed % gDbCheckHealthLogEveryNBatches.load() == 0)) {
// On debug builds, health-log every batch result; on release builds, health-log
// every N batches.
- HealthLogInterface::get(opCtx)->log(*entry);
- }
-
- if (MONGO_unlikely(sleepAfterExtraIndexKeysHashing.shouldFail())) {
- LOGV2_DEBUG(
- 3083201,
- 3,
- "Sleeping for 1 second due to sleepAfterExtraIndexKeysHashing failpoint");
- opCtx->sleepFor(Milliseconds(1000));
+ HealthLog::get(opCtx).log(*entry);
}
WriteConcernResult unused;
auto status = waitForWriteConcern(opCtx, stats.time, info.writeConcern, &unused);
if (!status.isOK()) {
- // TODO SERVER-89817: Add context with batch ID and lastKey once those are
- // backported.
- auto entry = dbCheckErrorHealthLogEntry(info.nss,
- "dbCheck failed waiting for writeConcern",
- OplogEntriesEnum::Batch,
- status);
- HealthLogInterface::get(opCtx)->log(*entry);
- return;
+ auto entry = dbCheckWarningHealthLogEntry(info.nss,
+ "dbCheck failed waiting for writeConcern",
+ OplogEntriesEnum::Batch,
+ status);
+ HealthLog::get(opCtx).log(*entry);
}
start = stats.lastKey;
@@ -585,12 +565,6 @@ private:
batch.setMaxKey(BSONKey(hasher->lastKey()));
batch.setReadTimestamp(readTimestamp);
- if (MONGO_unlikely(hangBeforeAddingDBCheckBatchToOplog.shouldFail())) {
- LOGV2(8589000,
- "Hanging dbCheck due to failpoint 'hangBeforeAddingDBCheckBatchToOplog'");
- hangBeforeAddingDBCheckBatchToOplog.pauseWhileSet();
- }
-
// Send information on this batch over the oplog.
result.time = _logOp(opCtx, info.nss, collection->uuid(), batch.toBSON());
result.readTimestamp = readTimestamp;