diff options
author | Jason Chan <jason.chan@mongodb.com> | 2020-02-10 22:51:38 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-02-10 22:51:38 +0000 |
commit | 6840394ee0a015939ac7b0497d27fbfe8dda71e4 (patch) | |
tree | a978cc8117ba2d59b354d605eec558e384100416 | |
parent | 09295d5476f3f5163abe0597128afc0e8f0b04ca (diff) | |
download | mongo-6840394ee0a015939ac7b0497d27fbfe8dda71e4.tar.gz |
SERVER-46049 Have _applyOperationsForTransaction() return a BadStatus instead of throwing
-rw-r--r-- | src/mongo/db/repl/transaction_oplog_application.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/mongo/db/repl/transaction_oplog_application.cpp b/src/mongo/db/repl/transaction_oplog_application.cpp index 2e31f9dc0e5..83bbe54deb9 100644 --- a/src/mongo/db/repl/transaction_oplog_application.cpp +++ b/src/mongo/db/repl/transaction_oplog_application.cpp @@ -71,10 +71,21 @@ Status _applyOperationsForTransaction(OperationContext* opCtx, if (!status.isOK()) { return status; } - } catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) { - if (oplogApplicationMode != repl::OplogApplication::Mode::kInitialSync && - oplogApplicationMode != repl::OplogApplication::Mode::kRecovering) - throw; + } catch (const DBException& ex) { + // Ignore NamespaceNotFound errors if we are in initial sync or recovering mode. + const bool ignoreException = ex.code() == ErrorCodes::NamespaceNotFound && + (oplogApplicationMode == repl::OplogApplication::Mode::kInitialSync || + oplogApplicationMode == repl::OplogApplication::Mode::kRecovering); + + if (!ignoreException) { + LOG(1) << "Error applying operation in transaction. " << redact(ex) + << "- oplog entry: " << redact(op.toBSON()); + return exceptionToStatus(); + } + LOG(1) << "Encountered but ignoring error: " << redact(ex) + << " while applying operations for transaction because we are either in initial " + "sync or recovering mode - oplog entry: " + << redact(op.toBSON()); } } return Status::OK(); |