Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-75993

Change Streams: Document key is not fully captured

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.5
    • Component/s: None
    • Query Execution
    • ALL
    • Hide

      Environment used:

      MongoDB Atlas M30 cluster, version: 6.0.5

      Show
      Environment used: MongoDB Atlas M30 cluster, version: 6.0.5

      The DocumentKey field of the change event does not capture a shard key if the value of the shard key is null

      Consider a collection emp with a shard key name.

      Inserting a document with no value for name, like
      {{db.emp.insertOne({"_id":"1001"}) 
      }}produces a change event with DocumentKey that contains only the _id field
      fullDocument=Document{{_id=1002, documentKey={"_id": "1001"}}}

      Similarly, updating the name field does not have the previous value of the shard key in the document key. That is,
      db.emp.updateOne({"_id":"1001","name":null},{$set:{"name":"Adam") }}also produces a change event with DocumentKey that contains only the _id field{{{}
      documentKey={"_id": "1001"}, updateDescription=UpdateDescription{removedFields=[], updatedFields=

      {"name": "Adam"}

      , truncatedArrays=[]}{}}}

      In both these operations, the DocumentKey field should contain a field for the name as well, like documentKey={"_id": "1001", "name": null}

       

      In our use case, we rely on the DocumentKey field to know the shard keys and their previous values. As a workaround we couldn't depend on retrieving the shard key from the config database when Change Streams is run as there is a possibility shard keys may have been refined between when the operation was performed and Change Streams was run.

      Expected behavior:
      Provide all the shard keys in DocumentKey even if their value is null.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            ajay2589@gmail.com Ajay Mathias
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: