summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMisha Tyulenev <misha.tyulenev@mongodb.com>2022-05-11 12:13:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-11 12:42:36 +0000
commit6e672225c74eb32b42bc2bdbc50d14c77234f9dd (patch)
tree034f95be33e29ba36b05e15293ccf1df9f3d33c6 /src
parentbf6c449f0379291a922a6235bc73309c0007ed72 (diff)
downloadmongo-6e672225c74eb32b42bc2bdbc50d14c77234f9dd.tar.gz
SERVER-62957 add reshardCollection change streams event
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/change_stream_event_transform.cpp9
-rw-r--r--src/mongo/db/pipeline/change_stream_filter_helpers.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/change_stream_event_transform.cpp b/src/mongo/db/pipeline/change_stream_event_transform.cpp
index 1ef1bb4e3b1..63d0aae84b6 100644
--- a/src/mongo/db/pipeline/change_stream_event_transform.cpp
+++ b/src/mongo/db/pipeline/change_stream_event_transform.cpp
@@ -345,6 +345,15 @@ Document ChangeStreamDefaultEventTransformation::applyTransformation(const Docum
break;
}
+ // Check whether this is a reshardCollection oplog entry.
+ if (!input.getNestedField("o2.reshardCollection").missing()) {
+ const auto o2Field = input[repl::OplogEntry::kObject2FieldName].getDocument();
+ operationType = DocumentSourceChangeStream::kReshardCollectionOpType;
+ operationDescription =
+ Value(copyDocExceptFields(o2Field, {"reshardCollection"_sd}));
+ break;
+ }
+
// Otherwise, o2.type determines the message type.
auto o2Type = input.getNestedField("o2.type");
tassert(5052200, "o2.type is missing from noop oplog event", !o2Type.missing());
diff --git a/src/mongo/db/pipeline/change_stream_filter_helpers.cpp b/src/mongo/db/pipeline/change_stream_filter_helpers.cpp
index 3919fad3f3f..bf8e0e1a4c6 100644
--- a/src/mongo/db/pipeline/change_stream_filter_helpers.cpp
+++ b/src/mongo/db/pipeline/change_stream_filter_helpers.cpp
@@ -321,6 +321,8 @@ std::unique_ptr<MatchExpression> buildInternalOpFilter(
serverGlobalParams.featureCompatibility)) {
internalOpTypeOrBuilder.append(
BSON("o2.refineCollectionShardKey" << BSON("$exists" << true)));
+
+ internalOpTypeOrBuilder.append(BSON("o2.reshardCollection" << BSON("$exists" << true)));
}
// Finalize the array of $or filter predicates.
diff --git a/src/mongo/db/pipeline/document_source_change_stream.h b/src/mongo/db/pipeline/document_source_change_stream.h
index 7fd9716cbc2..ab7489222c6 100644
--- a/src/mongo/db/pipeline/document_source_change_stream.h
+++ b/src/mongo/db/pipeline/document_source_change_stream.h
@@ -240,6 +240,7 @@ public:
static constexpr StringData kShardCollectionOpType = "shardCollection"_sd;
static constexpr StringData kMigrateLastChunkFromShardOpType = "migrateLastChunkFromShard"_sd;
static constexpr StringData kRefineCollectionShardKeyOpType = "refineCollectionShardKey"_sd;
+ static constexpr StringData kReshardCollectionOpType = "reshardCollection"_sd;
static constexpr StringData kModifyOpType = "modify"_sd;
// Default regex for collections match which prohibits system collections.