diff options
Diffstat (limited to 'src/mongo/db/repl/oplog_applier_utils.cpp')
| -rw-r--r-- | src/mongo/db/repl/oplog_applier_utils.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/mongo/db/repl/oplog_applier_utils.cpp b/src/mongo/db/repl/oplog_applier_utils.cpp index 65f8298af89..5029e0b57d6 100644 --- a/src/mongo/db/repl/oplog_applier_utils.cpp +++ b/src/mongo/db/repl/oplog_applier_utils.cpp @@ -34,8 +34,9 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/catalog/document_validation.h" -#include "mongo/db/concurrency/write_conflict_exception.h" +#include "mongo/db/concurrency/exception_util.h" #include "mongo/db/curop.h" +#include "mongo/db/curop_metrics.h" #include "mongo/db/db_raii.h" #include "mongo/db/repl/oplog_applier_utils.h" #include "mongo/db/repl/repl_server_parameters_gen.h" @@ -199,9 +200,11 @@ Status OplogApplierUtils::applyOplogEntryOrGroupedInsertsCommon( OpCounters* opCounters) { invariant(DocumentValidationSettings::get(opCtx).isSchemaValidationDisabled()); - auto op = entryOrGroupedInserts.getOp(); // Count each log op application as a separate operation, for reporting purposes CurOp individualOp(opCtx); + ON_BLOCK_EXIT([opCtx]() { recordCurOpMetricsOplogApplication(opCtx); }); + + auto op = entryOrGroupedInserts.getOp(); const NamespaceString nss(op.getNss()); auto opType = op.getOpType(); if (opType == OpTypeEnum::kNoop) { @@ -304,6 +307,7 @@ Status OplogApplierUtils::applyOplogBatchCommon( InsertGroup insertGroup( ops, opCtx, oplogApplicationMode, isDataConsistent, applyOplogEntryOrGroupedInserts); + const bool inStableRecovery = oplogApplicationMode == OplogApplication::Mode::kStableRecovering; for (auto it = ops->cbegin(); it != ops->cend(); ++it) { const OplogEntry& entry = **it; @@ -323,9 +327,18 @@ Status OplogApplierUtils::applyOplogBatchCommon( if (!status.isOK()) { // Tried to apply an update operation but the document is missing, there must be // a delete operation for the document later in the oplog. + // Server will crash on oplog application failure during recovery from stable + // checkpoint in the test environment. if (status == ErrorCodes::UpdateOperationFailed && (oplogApplicationMode == OplogApplication::Mode::kInitialSync || - oplogApplicationMode == OplogApplication::Mode::kRecovering)) { + OplogApplication::inRecovering(oplogApplicationMode))) { + if (inStableRecovery) { + repl::OplogApplication::checkOnOplogFailureForRecovery( + opCtx, + entry.getNss(), + redact(entry.toBSONForLogging()), + redact(status)); + } continue; } @@ -339,8 +352,14 @@ Status OplogApplierUtils::applyOplogBatchCommon( } catch (const DBException& e) { // SERVER-24927 If we have a NamespaceNotFound exception, then this document will be // dropped before initial sync or recovery ends anyways and we should ignore it. + // Server will crash on oplog application failure during recovery from stable checkpoint + // in the test environment. if (e.code() == ErrorCodes::NamespaceNotFound && entry.isCrudOpType() && allowNamespaceNotFoundErrorsOnCrudOps) { + if (inStableRecovery) { + repl::OplogApplication::checkOnOplogFailureForRecovery( + opCtx, entry.getNss(), redact(entry.toBSONForLogging()), redact(e)); + } continue; } |
