-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Change streams
-
None
-
Query Execution
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.