diff options
author | Benety Goh <benety@mongodb.com> | 2019-04-05 23:11:20 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2019-04-05 23:11:43 -0400 |
commit | 8035a39207bcdecf63a12c45c3884d2345bc50a6 (patch) | |
tree | d5cded0b93b881f95d0166a0b5f4cb7cd40d54c4 /src | |
parent | 31c5ea11448bd4a6eddcb2c3e42ad2d0b9b67f19 (diff) | |
download | mongo-8035a39207bcdecf63a12c45c3884d2345bc50a6.tar.gz |
SERVER-40169 OplogApplier::getNextApplierBatch() processes system.views oplog entries individually
This applies changes from commit f78e580dad60fa6ece39f34b3dcfc3ed95b85414.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/oplog_applier.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier_test.cpp | 12 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp index a3c4e1953f8..0602c4d261f 100644 --- a/src/mongo/db/repl/oplog_applier.cpp +++ b/src/mongo/db/repl/oplog_applier.cpp @@ -152,8 +152,13 @@ StatusWith<OplogApplier::Operations> OplogApplier::getNextApplierBatch( // 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. - if (entry.isCommand() && (entry.getCommandType() != OplogEntry::CommandType::kApplyOps || - entry.shouldPrepare())) { + // + // 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. + if ((entry.isCommand() && (entry.getCommandType() != OplogEntry::CommandType::kApplyOps || + entry.shouldPrepare())) || + entry.getNss().isSystemDotViews()) { if (ops.empty()) { // Apply commands one-at-a-time. ops.push_back(std::move(entry)); diff --git a/src/mongo/db/repl/oplog_applier_test.cpp b/src/mongo/db/repl/oplog_applier_test.cpp index d5bd62948e0..1ebf834a2b5 100644 --- a/src/mongo/db/repl/oplog_applier_test.cpp +++ b/src/mongo/db/repl/oplog_applier_test.cpp @@ -199,6 +199,18 @@ TEST_F(OplogApplierTest, GetNextApplierBatchGroupsUnpreparedApplyOpsOpWithOtherO ASSERT_EQUALS(srcOps[1], batch[1]); } +TEST_F(OplogApplierTest, GetNextApplierBatchReturnsSystemDotViewsOpInOwnBatch) { + OplogApplier::Operations srcOps; + srcOps.push_back(makeInsertOplogEntry( + 1, NamespaceString(dbName, NamespaceString::kSystemDotViewsCollectionName))); + srcOps.push_back(makeInsertOplogEntry(2, NamespaceString(dbName, "bar"))); + _applier->enqueue(_opCtx.get(), srcOps.cbegin(), srcOps.cend()); + + auto batch = unittest::assertGet(_applier->getNextApplierBatch(_opCtx.get(), _limits)); + ASSERT_EQUALS(1U, batch.size()) << toString(batch); + ASSERT_EQUALS(srcOps[0], batch[0]); +} + } // namespace } // namespace repl } // namespace mongo |