Compare commits

...

1 Commits

Author SHA1 Message Date
Chenhao Qu
aaa930aaed SERVER-56896 Log the duplicate key error concisley with arrtributes 2023-10-31 06:31:42 +11:00
2 changed files with 15 additions and 0 deletions

View File

@ -641,6 +641,14 @@ Status OplogApplierUtils::applyOplogBatchCommon(
"error"_attr = causedBy(redact(status)));
return status;
}
} catch (const ExceptionFor<ErrorCodes::DuplicateKey>& e) {
auto info = e.extraInfo<DuplicateKeyErrorInfo>();
LOGV2_FATAL_CONTINUE(5689600,
"Writer worker caught duplicate key exception",
"keyPattern"_attr = redact(info->getKeyPattern()),
"keyValue"_attr = redact(info->getDuplicatedKeyValue()),
"oplogEntry"_attr = redact(op->toBSONForLogging()));
return e.toStatus();
} 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.

View File

@ -509,6 +509,13 @@ boost::optional<Timestamp> ReplicationRecoveryImpl::recoverFromOplog(
opCtx, _consistencyMarkers->getAppliedThrough(opCtx), topOfOplog);
}
return stableTimestamp;
} catch (const ExceptionFor<ErrorCodes::DuplicateKey>& e) {
auto info = e.extraInfo<DuplicateKeyErrorInfo>();
LOGV2_FATAL_CONTINUE(5689601,
"Caught duplicate key exception during replication recovery",
"keyPattern"_attr = redact(info->getKeyPattern()),
"keyValue"_attr = redact(info->getDuplicatedKeyValue()));
std::terminate();
} catch (...) {
LOGV2_FATAL_CONTINUE(
21570, "Caught exception during replication recovery", "error"_attr = exceptionToStatus());