summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-05-10 10:56:48 -0400
committerBenety Goh <benety@mongodb.com>2019-05-10 10:56:59 -0400
commite06d151dcbe0aa26167add972f9249e57e654efa (patch)
tree78619ec098ed4ad120d939d9bc0811d3a16849a6
parentf93289333344bf097e2010899cc7ec19e52fe3cd (diff)
downloadmongo-e06d151dcbe0aa26167add972f9249e57e654efa.tar.gz
SERVER-40728 remove commitTransaction handling for unprepared transactions
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp11
-rw-r--r--src/mongo/db/repl/sync_tail.cpp40
2 files changed, 0 insertions, 51 deletions
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 6de2fbdf650..44c40e4f40e 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -593,17 +593,6 @@ Status rollback_internal::updateFixUpInfoFromLocalOplogEntry(OperationContext* o
case OplogEntry::CommandType::kAbortTransaction: {
return Status::OK();
}
- // TODO(SERVER-40728): 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();
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 0b93b7d373b..1b776f2ccf6 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -844,15 +844,6 @@ void SyncTail::_oplogApplication(ReplicationCoordinator* replCoord,
}
}
-// Returns whether an oplog entry represents a commitTransaction for a transaction which has not
-// been prepared. An entry is an unprepared commit if it has a boolean "prepared" field set to
-// false.
-inline bool isUnpreparedCommit(const OplogEntry& entry) {
- return entry.getCommandType() == OplogEntry::CommandType::kCommitTransaction &&
- entry.getObject()[CommitTransactionOplogObject::kPreparedFieldName].isBoolean() &&
- !entry.getObject()[CommitTransactionOplogObject::kPreparedFieldName].boolean();
-}
-
// Returns whether an oplog entry represents an applyOps which is a self-contained atomic operation,
// or the last applyOps of an unprepared transaction, as opposed to part of a prepared transaction
// or a non-final applyOps in an transaction.
@@ -1233,37 +1224,6 @@ void SyncTail::_fillWriterVectors(OperationContext* opCtx,
<< redact(op.toBSON())));
}
continue;
- } else if (isUnpreparedCommit(op)) {
- // TODO(SERVER-40728): Remove this block after SERVER-40676 because we will no longer
- // emit a commitTransaction oplog entry for an unprepared transaction. This code will
- // no longer be reachable because we will commit the unprepared transaction on the last
- // applyOps oplog entry, which will not contain a partialTxn field.
-
- // On commit of unprepared transactions, get transactional operations from the oplog and
- // fill writers with those operations.
- try {
- invariant(derivedOps);
- auto& partialTxnList = partialTxnOps[*op.getSessionId()];
- {
- // We need to use a ReadSourceScope avoid the reads of the transaction messing
- // up the state of the opCtx. In particular we do not want to set the
- // ReadSource to kLastApplied.
- ReadSourceScope readSourceScope(opCtx);
- derivedOps->emplace_back(
- readTransactionOperationsFromOplogChain(opCtx, op, partialTxnList));
- partialTxnList.clear();
- }
- // Transaction entries cannot have different session updates.
- _fillWriterVectors(opCtx, &derivedOps->back(), writerVectors, derivedOps, nullptr);
- } catch (...) {
- fassertFailedWithStatusNoTrace(
- 51116,
- exceptionToStatus().withContext(str::stream()
- << "Unable to read operations for transaction "
- << "commit "
- << redact(op.toBSON())));
- }
- continue;
}
auto& writer = (*writerVectors)[hash % numWriters];