summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Fuschetto <antonio.fuschetto@mongodb.com>2022-05-16 09:57:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-16 10:23:19 +0000
commit082481b93b0304b176d9f82e9c8d1304be85974c (patch)
tree374862941e373674a95ce607357b524d066d1842
parent1099c288284c77ba3b1591b0322e38d884f6db57 (diff)
downloadmongo-082481b93b0304b176d9f82e9c8d1304be85974c.tar.gz
SERVER-66423 Set the fromMigrate flag of DurableReplOperation entries only when FCV is 6.0 or greater
-rw-r--r--src/mongo/db/op_observer_impl.cpp9
-rw-r--r--src/mongo/db/repl/oplog_entry.h24
2 files changed, 27 insertions, 6 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index 6b7bd4ef6a8..75a0ff101c8 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -548,7 +548,7 @@ void OpObserverImpl::onInserts(OperationContext* opCtx,
"namespace"_attr = nss,
"document"_attr = iter->doc);
- operation.setFromMigrate(true);
+ operation.setFromMigrate_BackwardsCompatible(true);
}
txnParticipant.addTransactionOperation(opCtx, operation);
@@ -716,7 +716,8 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg
}
operation.setDestinedRecipient(
shardingWriteRouter.getReshardingDestinedRecipient(args.updateArgs->updatedDoc));
- operation.setFromMigrateIfTrue(args.updateArgs->source == OperationSource::kFromMigrate);
+ operation.setFromMigrateIfTrue_BackwardsCompatible(args.updateArgs->source ==
+ OperationSource::kFromMigrate);
txnParticipant.addTransactionOperation(opCtx, operation);
} else {
MutableOplogEntry oplogEntry;
@@ -858,7 +859,7 @@ void OpObserverImpl::onDelete(OperationContext* opCtx,
if (inBatchedWrite) {
auto operation =
MutableOplogEntry::makeDeleteOperation(nss, uuid, documentKey.getShardKeyAndId());
- operation.setFromMigrateIfTrue(args.fromMigrate);
+ operation.setFromMigrateIfTrue_BackwardsCompatible(args.fromMigrate);
batchedWriteContext.addBatchedOperation(opCtx, operation);
} else if (inMultiDocumentTransaction) {
const bool inRetryableInternalTransaction =
@@ -917,7 +918,7 @@ void OpObserverImpl::onDelete(OperationContext* opCtx,
}
operation.setDestinedRecipient(destinedRecipientDecoration(opCtx));
- operation.setFromMigrateIfTrue(args.fromMigrate);
+ operation.setFromMigrateIfTrue_BackwardsCompatible(args.fromMigrate);
txnParticipant.addTransactionOperation(opCtx, operation);
} else {
MutableOplogEntry oplogEntry;
diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h
index 2eb195c079a..40092e47f4e 100644
--- a/src/mongo/db/repl/oplog_entry.h
+++ b/src/mongo/db/repl/oplog_entry.h
@@ -189,9 +189,29 @@ public:
return variant_util::toVector<StmtId>(DurableReplOperation::getStatementIds());
}
- void setFromMigrateIfTrue(bool value) & {
- if (value)
+ /**
+ * Sets the `fromMigrate` flag for the individual statement of the `applyOps` entry.
+ *
+ * During a replica set downgrade from 6.0 to 5.3, there is a window in which the primary node
+ * uses the 6.0 binary and secondaries still use the 5.3 binary. The latter are unable to parse
+ * the `fromMigrate` field, so they would assert. This function skips setting the `fromMigrate`
+ * flag to avoid compatibility problems.
+ */
+ void setFromMigrate_BackwardsCompatible(bool value) {
+ if (serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
+ multiversion::FeatureCompatibilityVersion::kVersion_6_0)) {
setFromMigrate(value);
+ }
+ }
+
+ /**
+ * Same as `setFromMigrate_BackwardsCompatible` but set the `fromMigrate` flag only when the
+ * passed value is true.
+ */
+ void setFromMigrateIfTrue_BackwardsCompatible(bool value) {
+ if (value) {
+ setFromMigrate_BackwardsCompatible(true);
+ }
}
private: