diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2020-12-04 15:53:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-05 14:32:56 +0000 |
commit | 936fbbe8b45ed9a9a5ba78a327d3f0f6cb3974d2 (patch) | |
tree | f7e6ccb917c45a7d5fcdb7090d53bbf6c3c02040 | |
parent | dab2f1b235d3e94f05ec72c70b43220766102a11 (diff) | |
download | mongo-936fbbe8b45ed9a9a5ba78a327d3f0f6cb3974d2.tar.gz |
SERVER-53233 Fix change_streams_update_lookup_shard_metadata_missing.js to pull from the correct cursor
(cherry picked from commit 9b518b1c13000e6c0568ee43d520b6bd712e820a)
-rw-r--r-- | jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js b/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js index 8e91f160773..212a795e453 100644 --- a/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js +++ b/jstests/sharding/change_streams_update_lookup_shard_metadata_missing.js @@ -32,7 +32,7 @@ st.shardColl(mongosColl, {a: 1}, {a: 0}, {a: 1}); // Open a change stream on the collection. - const csCursor = mongosColl.watch(); + let csCursor = mongosColl.watch(); // Write one document onto shard0 and obtain its resume token. assert.commandWorked(mongosColl.insert({_id: 0, a: -100})); @@ -58,17 +58,19 @@ assert.soonNoExcept(() => assert.commandWorked( mongosColl.update({_id: 0}, {$set: {updated: true}}, false, true))); - // Resume the change stream with {fullDocument: 'updateLookup'}. - const cmdRes = assert.commandWorked(mongosColl.runCommand("aggregate", { - pipeline: [{$changeStream: {resumeAfter: resumeToken, fullDocument: "updateLookup"}}], - cursor: {} - })); - + // Resume the change stream with {fullDocument: 'updateLookup'}. Update lookup can successfully + // identify the document based on its _id alone so long as the _id is unique in the collection, + // so this alone does not prove that the multi-update wrote its shard key into the oplog. + csCursor = mongosColl.watch([], {resumeAfter: resumeToken, fullDocument: "updateLookup"}); assert.soon(() => csCursor.hasNext()); + assert.docEq(csCursor.next().fullDocument, {_id: 0, a: -100, updated: true}); - const updateObj = csCursor.next(); - - assert.eq(true, updateObj.updateDescription.updatedFields.updated); + // Now insert a new document with the same _id on the other shard. Update lookup will be able to + // distinguish between the two, proving that they both have full shard keys available. + assert.commandWorked(mongosColl.insert({_id: 0, a: 100})); + csCursor = mongosColl.watch([], {resumeAfter: resumeToken, fullDocument: "updateLookup"}); + assert.soon(() => csCursor.hasNext()); + assert.docEq(csCursor.next().fullDocument, {_id: 0, a: -100, updated: true}); st.stop(); })();
\ No newline at end of file |