Change event's documentKey lacks null/missing values

    • 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.

            Assignee:
            Unassigned
            Reporter:
            Ajay Vijayakumar (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: