summaryrefslogtreecommitdiff
path: root/src/mongo/db/op_observer_impl.cpp
diff options
context:
space:
mode:
authorRishab Joshi <rishab.joshi@mongodb.com>2021-11-05 13:29:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-05 13:54:46 +0000
commitc3b6bdf71ed1e39e3cfdc0f6738b085f352b333f (patch)
tree8845da45c125aaaad678232bd1e67d66b4640106 /src/mongo/db/op_observer_impl.cpp
parent67ef8cd1ed3d15cee09de7905f7ba9fedfba176d (diff)
downloadmongo-c3b6bdf71ed1e39e3cfdc0f6738b085f352b333f.tar.gz
SERVER-60236 Ensure pre-/post-images are not retained for documents belonging to migrated chunks.
Diffstat (limited to 'src/mongo/db/op_observer_impl.cpp')
-rw-r--r--src/mongo/db/op_observer_impl.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp
index b28e9c49a00..8b81abb21d7 100644
--- a/src/mongo/db/op_observer_impl.cpp
+++ b/src/mongo/db/op_observer_impl.cpp
@@ -713,9 +713,12 @@ void OpObserverImpl::onUpdate(OperationContext* opCtx, const OplogUpdateEntryArg
}
// Write a pre-image to the change streams pre-images collection if the node is the primary
- // and not performing an initial sync or a tenant migration.
+ // and not performing an initial sync or a tenant migration. A request to update a pre-image
+ // can come from chunk-migrate, ie. source of the request is 'fromMigrate', such events are
+ // filtered out by change streams and storing them in pre-image collection is redundant.
if (opCtx->isEnforcingConstraints() &&
- args.updateArgs->changeStreamPreAndPostImagesEnabledForCollection) {
+ args.updateArgs->changeStreamPreAndPostImagesEnabledForCollection &&
+ args.updateArgs->source != OperationSource::kFromMigrate) {
const auto& preImageDoc = args.updateArgs->preImageDoc;
tassert(5868600, "PreImage must be set", preImageDoc && !preImageDoc.get().isEmpty());
@@ -852,9 +855,11 @@ void OpObserverImpl::onDelete(OperationContext* opCtx,
}
// Write a pre-image to the change streams pre-images collection if the node is the primary
- // and not performing an initial sync or a tenant migration.
+ // and not performing an initial sync or a tenant migration. A request to delete a pre-image
+ // can come from chunk-migrate, ie. source of the request is 'fromMigrate', such events are
+ // filtered out by change streams and storing them in pre-image collection is redundant.
if (opCtx->isEnforcingConstraints() &&
- args.changeStreamPreAndPostImagesEnabledForCollection) {
+ args.changeStreamPreAndPostImagesEnabledForCollection && !args.fromMigrate) {
tassert(5868704, "Deleted document must be set", args.deletedDoc);
ChangeStreamPreImageId id(uuid, opTime.writeOpTime.getTimestamp(), 0);