[SERVER-68366] Avoid change streams broadcasting {fullDocument: "updateLookup"} queries to all shards when shard key field is missing Created: 27/Jul/22  Updated: 05/Dec/22

Status: Backlog
Project: Core Server
Component/s: Change streams
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Description   

MongoDB 4.4 enabled documents in a sharded collection to omit any or all of the shard key fields (SERVER-42390). ShardServerProcessInterface::lookupSingleDocument() ends up passing the document key directly into a $match stage. This means change streams may run a {_id: "hello"} query on a collection sharded by {a: 1, b: 1} and end up broadcasting the query to all shards to find the matching one.

Note that technically because change streams isn't reading at a single point-in-time across all of these shards it is technically possible for it to find multiple matching documents from the document being deleted + inserted across shards (e.g. from the shard key value being updated). This would lead to a ChangeStreamFatalError response.


Generated at Thu Feb 08 06:10:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.