summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_impl.cpp
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2021-04-26 20:23:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-05 18:13:49 +0000
commit946fb51b19e4943a069b8af1442ba5daeef61fa2 (patch)
tree2b428d27a1bd2beed1fc80ee8480424bfe2331ef /src/mongo/db/op_observer_impl.cpp
parent6701ac9e1cb8f42ae479d70f0fa6d1fa2b8bc995 (diff)
downloadmongo-946fb51b19e4943a069b8af1442ba5daeef61fa2.tar.gz
SERVER-54982 Test resumability of changes streams together with reshardCollection
Diffstat (limited to 'src/mongo/db/op_observer_impl.cpp')
-rw-r--r--src/mongo/db/op_observer_impl.cpp61
1 files changed, 57 insertions, 4 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index e2715df74aa..fd7bd32e97c 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -859,13 +859,24 @@ repl::OpTime OpObserverImpl::onDropCollection(OperationContext* opCtx,
const NamespaceString& collectionName,
OptionalCollectionUUID uuid,
std::uint64_t numRecords,
- const CollectionDropType dropType) {
+ CollectionDropType dropType) {
+ return onDropCollection(
+ opCtx, collectionName, uuid, numRecords, dropType, false /* markFromMigrate */);
+}
+
+repl::OpTime OpObserverImpl::onDropCollection(OperationContext* opCtx,
+ const NamespaceString& collectionName,
+ OptionalCollectionUUID uuid,
+ std::uint64_t numRecords,
+ const CollectionDropType dropType,
+ bool markFromMigrate) {
if (!collectionName.isSystemDotProfile()) {
// Do not replicate system.profile modifications.
MutableOplogEntry oplogEntry;
oplogEntry.setOpType(repl::OpTypeEnum::kCommand);
oplogEntry.setNss(collectionName.getCommandNS());
oplogEntry.setUuid(uuid);
+ oplogEntry.setFromMigrateIfTrue(markFromMigrate);
oplogEntry.setObject(BSON("drop" << collectionName.coll()));
oplogEntry.setObject2(makeObject2ForDropOrRename(numRecords));
logOperation(opCtx, &oplogEntry);
@@ -918,7 +929,6 @@ void OpObserverImpl::onDropIndex(OperationContext* opCtx,
logOperation(opCtx, &oplogEntry);
}
-
repl::OpTime OpObserverImpl::preRenameCollection(OperationContext* const opCtx,
const NamespaceString& fromCollection,
const NamespaceString& toCollection,
@@ -926,6 +936,24 @@ repl::OpTime OpObserverImpl::preRenameCollection(OperationContext* const opCtx,
OptionalCollectionUUID dropTargetUUID,
std::uint64_t numRecords,
bool stayTemp) {
+ return preRenameCollection(opCtx,
+ fromCollection,
+ toCollection,
+ uuid,
+ dropTargetUUID,
+ numRecords,
+ stayTemp,
+ false /* markFromMigrate */);
+}
+
+repl::OpTime OpObserverImpl::preRenameCollection(OperationContext* const opCtx,
+ const NamespaceString& fromCollection,
+ const NamespaceString& toCollection,
+ OptionalCollectionUUID uuid,
+ OptionalCollectionUUID dropTargetUUID,
+ std::uint64_t numRecords,
+ bool stayTemp,
+ bool markFromMigrate) {
BSONObjBuilder builder;
builder.append("renameCollection", fromCollection.ns());
builder.append("to", toCollection.ns());
@@ -938,6 +966,7 @@ repl::OpTime OpObserverImpl::preRenameCollection(OperationContext* const opCtx,
oplogEntry.setOpType(repl::OpTypeEnum::kCommand);
oplogEntry.setNss(fromCollection.getCommandNS());
oplogEntry.setUuid(uuid);
+ oplogEntry.setFromMigrateIfTrue(markFromMigrate);
oplogEntry.setObject(builder.done());
if (dropTargetUUID)
oplogEntry.setObject2(makeObject2ForDropOrRename(numRecords));
@@ -965,8 +994,32 @@ void OpObserverImpl::onRenameCollection(OperationContext* const opCtx,
OptionalCollectionUUID dropTargetUUID,
std::uint64_t numRecords,
bool stayTemp) {
- preRenameCollection(
- opCtx, fromCollection, toCollection, uuid, dropTargetUUID, numRecords, stayTemp);
+ onRenameCollection(opCtx,
+ fromCollection,
+ toCollection,
+ uuid,
+ dropTargetUUID,
+ numRecords,
+ stayTemp,
+ false /* markFromMigrate */);
+}
+
+void OpObserverImpl::onRenameCollection(OperationContext* const opCtx,
+ const NamespaceString& fromCollection,
+ const NamespaceString& toCollection,
+ OptionalCollectionUUID uuid,
+ OptionalCollectionUUID dropTargetUUID,
+ std::uint64_t numRecords,
+ bool stayTemp,
+ bool markFromMigrate) {
+ preRenameCollection(opCtx,
+ fromCollection,
+ toCollection,
+ uuid,
+ dropTargetUUID,
+ numRecords,
+ stayTemp,
+ markFromMigrate);
postRenameCollection(opCtx, fromCollection, toCollection, uuid, dropTargetUUID, stayTemp);
}