diff options
author | Benety Goh <benety@mongodb.com> | 2019-04-23 11:32:14 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2019-04-23 11:32:31 -0400 |
commit | d2da930b83a8e992c3b02875515e85077d9fa756 (patch) | |
tree | b14c8d5c9c7d7e0f69776e726d5fc84c519e0e20 /src/mongo/db | |
parent | 7667287a9b6daeb9e5d04742f46aa74cb7622f55 (diff) | |
download | mongo-d2da930b83a8e992c3b02875515e85077d9fa756.tar.gz |
SERVER-40365 rollback via refetch ignores commitTransaction oplog entry
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 2f9b3bc34d6..b7e505ffac8 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -48,6 +48,7 @@ #include "mongo/db/catalog_raii.h" #include "mongo/db/client.h" #include "mongo/db/commands.h" +#include "mongo/db/commands/txn_cmds_gen.h" #include "mongo/db/concurrency/replication_state_transition_lock_guard.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/db_raii.h" @@ -556,6 +557,17 @@ Status rollback_internal::updateFixUpInfoFromLocalOplogEntry(FixUpInfo& fixUpInf } return Status::OK(); } + // TODO(SERVER-39797): Remove commitTransaction handling for unprepared transactions. + case OplogEntry::CommandType::kCommitTransaction: { + IDLParserErrorContext ctx("commitTransaction"); + auto commitCommand = CommitTransactionOplogObject::parse(ctx, obj); + const bool prepared = !commitCommand.getPrepared() || *commitCommand.getPrepared(); + if (!prepared) { + log() << "Ignoring unprepared commitTransaction during rollback: " + << redact(oplogEntry.toBSON()); + return Status::OK(); + } + } default: { std::string message = str::stream() << "Can't roll back this command yet: " << " cmdname = " << first.fieldName(); |