Skip to content

Commit 8dd7310

Browse files
auto-revert-app[bot]MongoDB Bot
authored andcommitted
Revert "SERVER-95976 Introduce "matchCollectionUUIDForUpdateLookup" parameter in the change stream stage (#31141)" (#33299)
GitOrigin-RevId: 00f042c1dfa19cb3b5baae8a44b8cc046e55da4e
1 parent d4797bb commit 8dd7310

32 files changed

+217
-471
lines changed

etc/backports_required_for_multiversion_tests.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -573,22 +573,6 @@ last-continuous:
573573
ticket: SERVER-95670
574574
- test_file: jstests/sharding/query/owning_shard_expression.js
575575
ticket: SERVER-95670
576-
- test_file: jstests/core/write/update/upsert_duplicate_key_retry_collation.js
577-
ticket: SERVER-84089
578-
- test_file: jstests/change_streams/update_lookup_before_ddl.js
579-
ticket: SERVER-95976
580-
- test_file: jstests/change_streams/lookup_post_image.js
581-
ticket: SERVER-95976
582-
- test_file: jstests/sharding/change_stream_update_lookup_collation.js
583-
ticket: SERVER-95976
584-
- test_file: jstests/concurrency/fsm_workloads/upsert_unique_index_collation.js
585-
ticket: SERVER-94156
586-
- test_file: jstests/core/index/geo/geo_2d_point_near_zero.js
587-
ticket: SERVER-92930
588-
- test_file: jstests/replsets/sync_source_clears_post_failure.js
589-
ticket: SERVER-91960
590-
- test_file: jstests/sharding/catalog_cache_refresh_with_persisted_collection_cache_corrupted.js
591-
ticket: SERVER-95807
592576
- test_file: jstests/sharding/timeseries_query_extended_range.js
593577
ticket: SERVER-73641
594578
- test_file: jstests/core/timeseries/timeseries_index_partial.js
@@ -1222,22 +1206,6 @@ last-lts:
12221206
ticket: SERVER-95670
12231207
- test_file: jstests/sharding/query/owning_shard_expression.js
12241208
ticket: SERVER-95670
1225-
- test_file: jstests/core/write/update/upsert_duplicate_key_retry_collation.js
1226-
ticket: SERVER-84089
1227-
- test_file: jstests/change_streams/update_lookup_before_ddl.js
1228-
ticket: SERVER-95976
1229-
- test_file: jstests/change_streams/lookup_post_image.js
1230-
ticket: SERVER-95976
1231-
- test_file: jstests/sharding/change_stream_update_lookup_collation.js
1232-
ticket: SERVER-95976
1233-
- test_file: jstests/concurrency/fsm_workloads/upsert_unique_index_collation.js
1234-
ticket: SERVER-94156
1235-
- test_file: jstests/core/index/geo/geo_2d_point_near_zero.js
1236-
ticket: SERVER-92930
1237-
- test_file: jstests/replsets/sync_source_clears_post_failure.js
1238-
ticket: SERVER-91960
1239-
- test_file: jstests/sharding/catalog_cache_refresh_with_persisted_collection_cache_corrupted.js
1240-
ticket: SERVER-95807
12411209
- test_file: jstests/sharding/timeseries_query_extended_range.js
12421210
ticket: SERVER-73641
12431211
- test_file: jstests/core/timeseries/timeseries_index_partial.js

jstests/change_streams/lookup_post_image.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ assertCreateCollection(db, coll.getName());
188188
// collection.
189189
assert.commandWorked(coll.insert({_id: "fullDocument is lookup 2"}));
190190

191-
// If this test is running with secondary read preference, it's necessary for the insert
192-
// to propagate to all secondary nodes and be available for majority reads before we can
193-
// assume looking up the document will succeed.
194-
FixtureHelpers.awaitLastOpCommitted(db);
195-
196191
// After a collection has been dropped and re-created, verify a change stream can be created with
197192
// 'fullDocument: updateLookup' using a resume token from before the collection was dropped.
198193
cursor = cst.startWatchingChanges({
@@ -210,13 +205,13 @@ assert.eq(latestChange.operationType, "insert");
210205
assert(latestChange.hasOwnProperty("fullDocument"));
211206
assert.eq(latestChange.fullDocument, {_id: "fullDocument is lookup 2"});
212207

213-
// The next entry is the 'update' operation. Confirm that the next entry's post-image is not-null
214-
// even though the original collection has been dropped and the new incarnation of the collection
215-
// with the same name has a different UUID.
208+
// The next entry is the 'update' operation. Confirm that the next entry's post-image is null
209+
// because the original collection (i.e. the collection that the 'update' was applied to) has
210+
// been dropped and the new incarnation of the collection has a different UUID.
216211
latestChange = cst.getOneChange(cursor);
217212
assert.eq(latestChange.operationType, "update");
218213
assert(latestChange.hasOwnProperty("fullDocument"));
219-
assert.eq(latestChange.fullDocument, {"_id": "fullDocument is lookup 2"});
214+
assert.eq(latestChange.fullDocument, null);
220215

221216
jsTestLog("Testing full document lookup with a real getMore");
222217
assert.commandWorked(coll.insert({_id: "getMoreEnabled"}));

jstests/change_streams/oplog_rewrite/change_stream_null_existence_eq_rewrite_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const startPoint = db.getMongo().watch().getResumeToken();
2222
const numDocs = 8;
2323

2424
// Generate a write workload for the change stream to consume.
25-
generateChangeStreamWriteWorkload(testDB, collName, numDocs, false /* includeInvalidatingEvents */);
25+
generateChangeStreamWriteWorkload(testDB, collName, numDocs);
2626

2727
// Function to generate a list of all paths to be tested from those observed in the event stream.
2828
function traverseEvent(event, outputMap, prefixPath = "") {

jstests/change_streams/update_lookup_before_ddl.js

Lines changed: 0 additions & 127 deletions
This file was deleted.

jstests/noPassthrough/aggregation_cursor_invalidations.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ res = assert.commandWorked(testDB.runCommand({
134134
from: foreignCollection.getName(),
135135
localField: 'local',
136136
foreignField: 'foreign',
137-
pipeline: [{$project: {a: 1}}],
138137
as: 'results',
139138
}
140139
},
@@ -147,8 +146,10 @@ res = assert.commandWorked(testDB.runCommand({
147146
foreignCollection.drop();
148147
getMoreCollName = res.cursor.ns.substr(res.cursor.ns.indexOf('.') + 1);
149148
res = testDB.runCommand({getMore: res.cursor.id, collection: getMoreCollName});
150-
assert.commandWorked(res,
151-
'expected getMore to succeed despite the foreign collection being dropped');
149+
assert.commandFailedWithCode(
150+
res,
151+
[ErrorCodes.QueryPlanKilled, ErrorCodes.NamespaceNotFound],
152+
'expected getMore to fail when the foreign collection has been dropped');
152153

153154
// Make sure the cursors were cleaned up.
154155
assertNoOpenCursorsOnSourceCollection();
@@ -213,9 +214,10 @@ res = assert.commandWorked(testDB.runCommand({
213214
foreignCollection.drop();
214215
getMoreCollName = res.cursor.ns.substr(res.cursor.ns.indexOf('.') + 1);
215216
res = testDB.runCommand({getMore: res.cursor.id, collection: getMoreCollName});
216-
assert.commandWorked(res,
217-
'expected getMore to succeed despite the foreign collection being dropped');
218-
217+
assert.commandFailedWithCode(
218+
res,
219+
ErrorCodes.NamespaceNotFound,
220+
'expected getMore to fail when the foreign collection has been dropped');
219221
// Make sure the cursors were cleaned up.
220222
assertNoOpenCursorsOnSourceCollection();
221223

@@ -244,8 +246,10 @@ res = assert.commandWorked(testDB.runCommand({
244246
foreignCollection.drop();
245247
getMoreCollName = res.cursor.ns.substr(res.cursor.ns.indexOf('.') + 1);
246248
res = testDB.runCommand({getMore: res.cursor.id, collection: getMoreCollName});
247-
assert.commandWorked(res,
248-
'expected getMore to succeed despite the foreign collection being dropped');
249+
assert.commandFailedWithCode(
250+
res,
251+
ErrorCodes.NamespaceNotFound,
252+
'expected getMore to fail when the foreign collection has been dropped');
249253

250254
// Make sure the cursors were cleaned up.
251255
assertNoOpenCursorsOnSourceCollection();

jstests/sharding/change_stream_update_lookup_collation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ for (let nextDocKey of [{shardKey: "abc", _id: "abc_1"}, {shardKey: "ABC", _id:
101101
assert.eq(next.documentKey, nextDocKey, tojson(next));
102102
assert.docEq(Object.merge(nextDocKey, {updatedCount: 1}), next.fullDocument);
103103
}
104-
assert.eq(numIdIndexUsages(st.rs0.getPrimary()), idIndexUsagesPreIteration.shard0);
105-
assert.eq(numIdIndexUsages(st.rs1.getPrimary()), idIndexUsagesPreIteration.shard1);
104+
assert.eq(numIdIndexUsages(st.rs0.getPrimary()), idIndexUsagesPreIteration.shard0 + 1);
105+
assert.eq(numIdIndexUsages(st.rs1.getPrimary()), idIndexUsagesPreIteration.shard1 + 1);
106106

107107
changeStream.close();
108108

@@ -147,8 +147,8 @@ for (let nextDocKey of [{shardKey: "ABC", _id: "abc_1"}, {shardKey: "abc", _id:
147147
assert.eq(next.documentKey, nextDocKey, tojson(next));
148148
assert.docEq(Object.merge(nextDocKey, {updatedCount: 2}), next.fullDocument);
149149
}
150-
assert.eq(numIdIndexUsages(st.rs0.getPrimary()), idIndexUsagesPreIteration.shard0);
151-
assert.eq(numIdIndexUsages(st.rs1.getPrimary()), idIndexUsagesPreIteration.shard1);
150+
assert.eq(numIdIndexUsages(st.rs0.getPrimary()), idIndexUsagesPreIteration.shard0 + 1);
151+
assert.eq(numIdIndexUsages(st.rs1.getPrimary()), idIndexUsagesPreIteration.shard1 + 1);
152152

153153
strengthOneChangeStream.close();
154154

src/mongo/db/pipeline/document_source_change_stream.idl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ structs:
185185
"updateDescription" field in update events will be omitted.
186186
query_shape: literal
187187

188-
matchCollectionUUIDForUpdateLookup:
189-
type: optionalBool
190-
description: An internal flag that ensures that updateLookup is performed on the
191-
collection where UUID matches the one from the corresponding change
192-
event. In case of a mismatch, null document will be returned.
193-
query_shape: literal
194-
195188
DocumentSourceChangeStreamOplogMatchSpec:
196189
strict: true
197190
description: A document used to specify the $_internalChangeStreamOplogMatch stage of an

src/mongo/db/pipeline/document_source_change_stream_add_post_image.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,9 @@ boost::optional<Document> DocumentSourceChangeStreamAddPostImage::lookupLatestPo
204204
// Update lookup queries sent from mongoS to shards are allowed to use speculative majority
205205
// reads. Even if the lookup itself succeeded, it may not have returned any results if the
206206
// document was deleted in the time since the update op.
207-
tassert(9797601, "UUID should be present in the resume token", resumeTokenData.uuid);
208-
try {
209-
// In case we are running $changeStreams and are performing updateLookup, we do not pass
210-
// 'collectionUUID' to avoid any UUID validation on the target collection. UUID of the
211-
// target collection should only be checked if 'matchCollectionUUIDForUpdateLookup' flag has
212-
// been passed.
213-
auto collectionUUID = pExpCtx->changeStreamSpec->getMatchCollectionUUIDForUpdateLookup()
214-
? boost::optional<UUID>(*resumeTokenData.uuid)
215-
: boost::none;
216-
return pExpCtx->mongoProcessInterface->lookupSingleDocument(
217-
pExpCtx, nss, std::move(collectionUUID), documentKey, std::move(readConcern));
218-
} catch (const ExceptionFor<ErrorCodes::TooManyMatchingDocuments>& ex) {
219-
uasserted(ErrorCodes::ChangeStreamFatalError, ex.what());
220-
}
207+
invariant(resumeTokenData.uuid);
208+
return pExpCtx->mongoProcessInterface->lookupSingleDocument(
209+
pExpCtx, nss, *resumeTokenData.uuid, documentKey, std::move(readConcern));
221210
}
222211

223212
Value DocumentSourceChangeStreamAddPostImage::doSerialize(const SerializationOptions& opts) const {

src/mongo/db/pipeline/document_source_change_stream_add_post_image_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ TEST_F(DocumentSourceChangeStreamAddPostImageTest, ShouldErrorIfDocumentKeyIsNot
326326
std::make_unique<MockMongoInterface>(std::move(foreignCollection));
327327

328328
ASSERT_THROWS_CODE(
329-
lookupChangeStage->getNext(), AssertionException, ErrorCodes::ChangeStreamFatalError);
329+
lookupChangeStage->getNext(), AssertionException, ErrorCodes::TooManyMatchingDocuments);
330330
}
331331

332332
TEST_F(DocumentSourceChangeStreamAddPostImageTest, ShouldPropagatePauses) {

src/mongo/db/pipeline/document_source_change_stream_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct MockMongoInterface final : public ExecutableStubMongoProcessInterface {
171171
boost::optional<Document> lookupSingleDocument(
172172
const boost::intrusive_ptr<ExpressionContext>& expCtx,
173173
const NamespaceString& nss,
174-
boost::optional<UUID> collectionUUID,
174+
UUID collectionUUID,
175175
const Document& documentKey,
176176
boost::optional<BSONObj> readConcern) final {
177177
Matcher matcher(documentKey.toBson(), expCtx);

0 commit comments

Comments
 (0)