summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/dbcheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/dbcheck.cpp')
-rw-r--r--src/mongo/db/repl/dbcheck.cpp51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/mongo/db/repl/dbcheck.cpp b/src/mongo/db/repl/dbcheck.cpp
index c02ebb9512b..cc140a71817 100644
--- a/src/mongo/db/repl/dbcheck.cpp
+++ b/src/mongo/db/repl/dbcheck.cpp
@@ -27,6 +27,8 @@
* 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"
@@ -43,10 +45,13 @@
#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 {
@@ -409,6 +414,14 @@ Status dbCheckBatchOnSecondary(OperationContext* opCtx,
// 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));
+ }
} catch (const DBException& exception) {
// In case of an error, report it to the health log,
auto logEntry = dbCheckErrorHealthLogEntry(
@@ -438,7 +451,6 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
IDLParserErrorContext ctx("o");
auto skipDbCheck = mode != OplogApplication::Mode::kSecondary;
- auto severity = skipDbCheck ? SeverityEnum::Warning : SeverityEnum::Info;
std::string oplogApplicationMode;
if (mode == OplogApplication::Mode::kInitialSync) {
oplogApplicationMode = "initial sync";
@@ -459,7 +471,7 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
// 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;
+ BSONObj batchStart, batchEnd, batchId;
if (!invocation.getBatchStart()) {
batchStart = BSON("_id" << invocation.getMinKey().elem());
} else {
@@ -472,21 +484,42 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
}
*/
- if (!skipDbCheck) {
+ 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,
- "cannot execute dbcheck due to ongoing " + oplogApplicationMode,
- type,
- boost::none /*data*/);
+ invocation.getNss(), SeverityEnum::Warning, warningMsg, type, boost::none /*data*/);
+
HealthLogInterface::get(Client::getCurrent()->getServiceContext())
->log(*healthLogEntry);
return Status::OK();
@@ -500,7 +533,7 @@ Status dbCheckOplogCommand(OperationContext* opCtx,
case OplogEntriesEnum::Stop:
const auto healthLogEntry = mongo::dbCheckHealthLogEntry(
boost::none /*nss*/,
- severity,
+ skipDbCheck ? SeverityEnum::Warning : SeverityEnum::Info,
skipDbCheck ? "cannot execute dbcheck due to ongoing " + oplogApplicationMode : "",
type,
boost::none /*data*/