summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2019-01-31 17:46:18 -0500
committerJack Mulrow <jack.mulrow@mongodb.com>2019-02-20 14:03:36 -0500
commit0d79175a88ee958722c0ffb276606949e695d028 (patch)
tree627304462855987caff0626bbaea3852cdf65241 /src/mongo/db/repl
parentc94633ce354291ce3a61a1eed7d8a66c11b54c04 (diff)
downloadmongo-0d79175a88ee958722c0ffb276606949e695d028.tar.gz
SERVER-36498 Gate "state" field in config.transactions on FCV and remove entries with state on downgrade
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/session_update_tracker.cpp32
-rw-r--r--src/mongo/db/repl/sync_tail.cpp6
2 files changed, 24 insertions, 14 deletions
diff --git a/src/mongo/db/repl/session_update_tracker.cpp b/src/mongo/db/repl/session_update_tracker.cpp
index 32cc3466879..958e77f1497 100644
--- a/src/mongo/db/repl/session_update_tracker.cpp
+++ b/src/mongo/db/repl/session_update_tracker.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/oplog_entry.h"
+#include "mongo/db/server_options.h"
#include "mongo/db/session.h"
#include "mongo/db/session_txn_record_gen.h"
#include "mongo/util/assert_util.h"
@@ -68,20 +69,25 @@ boost::optional<repl::OplogEntry> createMatchingTransactionTableUpdate(
newTxnRecord.setLastWriteOpTime(entry.getOpTime());
newTxnRecord.setLastWriteDate(*entry.getWallClockTime());
- switch (entry.getCommandType()) {
- case repl::OplogEntry::CommandType::kApplyOps:
- newTxnRecord.setState(entry.shouldPrepare() ? DurableTxnStateEnum::kPrepared
- : DurableTxnStateEnum::kCommitted);
- break;
- case repl::OplogEntry::CommandType::kCommitTransaction:
- newTxnRecord.setState(DurableTxnStateEnum::kCommitted);
- break;
- case repl::OplogEntry::CommandType::kAbortTransaction:
- newTxnRecord.setState(DurableTxnStateEnum::kAborted);
- break;
- default:
- break;
+ // "state" is a new field in 4.2.
+ if (serverGlobalParams.featureCompatibility.getVersion() >=
+ ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42) {
+ switch (entry.getCommandType()) {
+ case repl::OplogEntry::CommandType::kApplyOps:
+ newTxnRecord.setState(entry.shouldPrepare() ? DurableTxnStateEnum::kPrepared
+ : DurableTxnStateEnum::kCommitted);
+ break;
+ case repl::OplogEntry::CommandType::kCommitTransaction:
+ newTxnRecord.setState(DurableTxnStateEnum::kCommitted);
+ break;
+ case repl::OplogEntry::CommandType::kAbortTransaction:
+ newTxnRecord.setState(DurableTxnStateEnum::kAborted);
+ break;
+ default:
+ break;
+ }
}
+
return newTxnRecord.toBSON();
}();
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index c811ff0dd82..6ac27643f1e 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -907,12 +907,16 @@ bool SyncTail::tryPopAndWaitForMore(OperationContext* opCtx,
// Commands must be processed one at a time. The only exception to this is applyOps because
// applyOps oplog entries are effectively containers for CRUD operations. Therefore, it is safe
// to batch applyOps commands with CRUD operations when reading from the oplog buffer.
+ //
// Oplog entries on 'system.views' should also be processed one at a time. View catalog
// immediately reflects changes for each oplog entry so we can see inconsistent view catalog if
// multiple oplog entries on 'system.views' are being applied out of the original order.
+ //
+ // Process updates to 'admin.system.version' individually as well so the secondary's FCV when
+ // processing each operation matches the primary's when committing that operation.
if ((entry.isCommand() &&
(entry.getCommandType() != OplogEntry::CommandType::kApplyOps || entry.shouldPrepare())) ||
- entry.getNss().isSystemDotViews()) {
+ entry.getNss().isSystemDotViews() || entry.getNss().isServerConfigurationCollection()) {
if (ops->getCount() == 1) {
// apply commands one-at-a-time
_consume(opCtx, oplogBuffer);