-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
0
Problem
Change streams include a `documentKey` to allow clients to query for individual documents even if multiple shards contain documents with the same _id.
The server, though, omits shard key fields from `documentKey` if the document lacks that field. That is: for a collection sharded on (sk: 1, _id: 1), if a document is missing the sk field, its documentKey in the change stream is just (_id: 1 ) rather than (sk: null, _id: 1). Thus, if some other shard contains (sk: 123, _id: 1), a query on that “abbreviated” documentKey will return 2 documents rather than 1.
The server must send (sk: null, _id: 1) as the documentKey in this case, even if the `sk` field is missing from the document.
(NB: the server treats missing shard key fields as null internally.)
Solution
Change event documentKeys should include null or missing shard key fields.
Impact
For users: `documentKey` will work for cases where the document lacks one or more shard-key fields.
For MongoDB: WRITING-31304 proposes a simplification of mongosync that removes some longstanding technical debt and will allow us to migrate heavier workloads. Given, though, that `shardCollection` events do not reliably precede all relevant CRUD events, we can’t implement this without dropping `shardCollection` support.
- is related to
-
SERVER-68366 Avoid change streams broadcasting {fullDocument: "updateLookup"} queries to all shards when shard key field is missing
-
- Backlog
-
- related to
-
SERVER-75993 Change Streams: Document key is not fully captured
-
- Backlog
-