summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Caplinger <christopher.caplinger@mongodb.com>2022-06-23 00:59:11 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-23 01:50:02 +0000
commit8d04153c3db149e9f6224e3c2cab31b8d66154fe (patch)
tree60389d86cf066e9bebf37ec3fac673bddf09dc9c
parent09d251fb165d7f5976ed707a3ed16d12f6da945f (diff)
downloadmongo-8d04153c3db149e9f6224e3c2cab31b8d66154fe.tar.gz
SERVER-66919: Serialize all writes to tenant migration namespaces
-rw-r--r--src/mongo/db/namespace_string.cpp1
-rw-r--r--src/mongo/db/repl/oplog_applier_impl.cpp15
-rw-r--r--src/mongo/db/repl/oplog_applier_impl_test.cpp36
3 files changed, 1 insertions, 51 deletions
diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp
index dd17cf16877..633ab3ce8ce 100644
--- a/src/mongo/db/namespace_string.cpp
+++ b/src/mongo/db/namespace_string.cpp
@@ -269,6 +269,7 @@ bool NamespaceString::mustBeAppliedInOwnOplogBatch() const {
return isSystemDotViews() || isServerConfigurationCollection() || isPrivilegeCollection() ||
_ns == kDonorReshardingOperationsNamespace.ns() ||
_ns == kForceOplogBatchBoundaryNamespace.ns() ||
+ _ns == kTenantMigrationDonorsNamespace.ns() ||
_ns == kTenantMigrationRecipientsNamespace.ns() || _ns == kConfigsvrShardsNamespace.ns();
}
diff --git a/src/mongo/db/repl/oplog_applier_impl.cpp b/src/mongo/db/repl/oplog_applier_impl.cpp
index e9ca22da35c..575035711e0 100644
--- a/src/mongo/db/repl/oplog_applier_impl.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl.cpp
@@ -623,8 +623,6 @@ void OplogApplierImpl::_deriveOpsAndFillWriterVectors(
LogicalSessionIdMap<std::vector<OplogEntry*>> partialTxnOps;
CachedCollectionProperties collPropertiesCache;
- // Used to serialize writes to the tenant migrations donor and recipient namespaces.
- boost::optional<uint32_t> tenantMigrationsWriterId;
for (auto&& op : *ops) {
// If the operation's optime is before or the same as the beginApplyingOpTime we don't want
// to apply it, so don't include it in writerVectors.
@@ -706,19 +704,6 @@ void OplogApplierImpl::_deriveOpsAndFillWriterVectors(
continue;
}
- // Writes to the tenant migration namespaces must be serialized to preserve the order of
- // migration and access blocker states.
- if (op.getNss() == NamespaceString::kTenantMigrationDonorsNamespace ||
- op.getNss() == NamespaceString::kTenantMigrationRecipientsNamespace) {
- auto writerId = OplogApplierUtils::addToWriterVector(
- opCtx, &op, writerVectors, &collPropertiesCache, tenantMigrationsWriterId);
- if (!tenantMigrationsWriterId) {
- tenantMigrationsWriterId.emplace(writerId);
- } else {
- invariant(writerId == *tenantMigrationsWriterId);
- }
- continue;
- }
OplogApplierUtils::addToWriterVector(opCtx, &op, writerVectors, &collPropertiesCache);
}
}
diff --git a/src/mongo/db/repl/oplog_applier_impl_test.cpp b/src/mongo/db/repl/oplog_applier_impl_test.cpp
index 9485fc8ccc2..b734004bb28 100644
--- a/src/mongo/db/repl/oplog_applier_impl_test.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl_test.cpp
@@ -2644,42 +2644,6 @@ TEST_F(OplogApplierImplWithSlowAutoAdvancingClockTest, DoNotLogNonSlowOpApplicat
ASSERT_EQUALS(0, countTextFormatLogLinesContaining(expected.str()));
}
-TEST_F(OplogApplierImplTest, SerializeOplogApplicationOfWritesToTenantMigrationNamespaces) {
- auto writerPool = makeReplWriterPool();
- NoopOplogApplierObserver observer;
- TrackOpsAppliedApplier oplogApplier(
- nullptr, // executor
- nullptr, // oplogBuffer
- &observer,
- ReplicationCoordinator::get(_opCtx.get()),
- getConsistencyMarkers(),
- getStorageInterface(),
- repl::OplogApplier::Options(repl::OplogApplication::Mode::kSecondary),
- writerPool.get());
-
- const auto donorNss = NamespaceString::kTenantMigrationDonorsNamespace;
- const auto recipientNss = NamespaceString::kTenantMigrationRecipientsNamespace;
-
- std::vector<OplogEntry> opsToApply;
- opsToApply.push_back(
- makeDeleteDocumentOplogEntry({Timestamp(Seconds(2), 0), 1LL}, donorNss, BSON("_id" << 2)));
- opsToApply.push_back(makeInsertDocumentOplogEntry(
- {Timestamp(Seconds(3), 0), 1LL}, recipientNss, BSON("_id" << 3)));
- opsToApply.push_back(makeDeleteDocumentOplogEntry(
- {Timestamp(Seconds(4), 0), 1LL}, recipientNss, BSON("_id" << 3)));
- opsToApply.push_back(
- makeInsertDocumentOplogEntry({Timestamp(Seconds(5), 0), 1LL}, donorNss, BSON("_id" << 4)));
-
- ASSERT_OK(oplogApplier.applyOplogBatch(_opCtx.get(), opsToApply));
- const auto applied = oplogApplier.getOperationsApplied();
- ASSERT_EQ(4U, applied.size());
- ASSERT_BSONOBJ_EQ(opsToApply[0].getEntry().toBSON(), applied[0].getEntry().toBSON());
- ASSERT_BSONOBJ_EQ(opsToApply[1].getEntry().toBSON(), applied[1].getEntry().toBSON());
- ASSERT_BSONOBJ_EQ(opsToApply[2].getEntry().toBSON(), applied[2].getEntry().toBSON());
- ASSERT_BSONOBJ_EQ(opsToApply[3].getEntry().toBSON(), applied[3].getEntry().toBSON());
-}
-
-
class OplogApplierImplTxnTableTest : public OplogApplierImplTest {
public:
void setUp() override {