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

Change Stream: Shard keys not captured in documentKey on delete operations performed directly on mongo instances

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.4
    • Component/s: None
    • Labels:
    • Query Execution
    • ALL
    • Hide

      Case 1: Connect using mongodb+srv URL
      mongosh "mongodb+srv://xxxx.yyyy.mongodb.net"  

      Perform delete operation on a collection with shard key "name"

      ChangeStream captured has document key - documentKey={"name": "1", "_id": 1}

      Both _id and shard key value are present.

      Case 2: Connect to mongos
      mongosh "mongodb://xxxx-shard-00-00.yyyy.mongodb.net:27016,xxxx-shard-00-01.yyyy.mongodb.net:27016,xxxx-shard-00-02.yyyy.mongodb.net:27016" --tls
      Perform delete operation on a collection with shard key "name"

      ChangeStream captured has document key - documentKey={"name": "6", "_id": 6}

      Both _id and shard key value are present.

      Case 3: Connect to mongod instances
      mongosh "mongodb://xxxx-shard-00-00.yyyy.mongodb.net:27017,xxxx-shard-00-01.yyyy.mongodb.net:27017,xxxx-shard-00-02.yyyy.mongodb.net:27017" --tls
      Perform delete operation on a collection with shard key "name"

      ChangeStream captured has document key - documentKey={"_id": 2}

      Only _id is present, although the document had a non-empty shard key value.

      Show
      Case 1 : Connect using mongodb+srv URL mongosh "mongodb+srv://xxxx.yyyy.mongodb.net"   Perform delete operation on a collection with shard key "name" ChangeStream captured has document key - documentKey={"name": "1", "_id": 1 } Both _id and shard key value are present. Case 2 : Connect to mongos mongosh "mongodb://xxxx-shard-00-00.yyyy.mongodb.net:27016,xxxx-shard-00-01.yyyy.mongodb.net:27016,xxxx-shard-00-02.yyyy.mongodb.net:27016" --tls Perform delete operation on a collection with shard key "name" ChangeStream captured has document key - documentKey={"name": "6", "_id": 6 } Both _id and shard key value are present. Case 3 : Connect to mongod instances mongosh "mongodb://xxxx-shard-00-00.yyyy.mongodb.net:27017,xxxx-shard-00-01.yyyy.mongodb.net:27017,xxxx-shard-00-02.yyyy.mongodb.net:27017" --tls Perform delete operation on a collection with shard key "name" ChangeStream captured has document key - documentKey={"_id": 2 } Only _id is present, although the document had a non-empty shard key value.
    • QE 2023-09-18, QE 2023-10-02, QE 2023-10-16, QE 2023-10-30, QE 2023-11-13, QE 2023-11-27

      Change Stream: Shard keys are captured in documentKey on delete operations performed when connected to mongos and mongodb+srv, but not directly to MongoDB instances.

      Perform the following operations listed in the Steps To Reproduce section while reading from ChangeStream.

      It can be seen that shard keys and their values are captured by the change stream when the delete operations were performed by mongosh connections that were connected to mongos or mongodb+srv (Cases 1 & 2), but not by connections that were directly connected to the MongoDB database instances (Case 3). This behavior is exhibited only for delete operations. It was noted that update change events had shard keys in their document keys in all these scenarios.

            Assignee:
            sebastien.mendez@mongodb.com Sebastien Mendez
            Reporter:
            ajay2589@gmail.com Ajay Mathias
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: