diff options
author | Misha Tyulenev <misha.tyulenev@mongodb.com> | 2022-05-11 12:13:09 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-11 12:42:36 +0000 |
commit | 6e672225c74eb32b42bc2bdbc50d14c77234f9dd (patch) | |
tree | 034f95be33e29ba36b05e15293ccf1df9f3d33c6 /src/mongo/db/pipeline | |
parent | bf6c449f0379291a922a6235bc73309c0007ed72 (diff) | |
download | mongo-6e672225c74eb32b42bc2bdbc50d14c77234f9dd.tar.gz |
SERVER-62957 add reshardCollection change streams event
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r-- | src/mongo/db/pipeline/change_stream_event_transform.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/pipeline/change_stream_filter_helpers.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_change_stream.h | 1 |
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. |