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

Existing $recordId field hidden when showRecordId:true is used

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • ALL

      We can insert documents with $recordId as a field. However, on querying with showRecordId:true, the field is overwritten by the true recordId instead of being displayed. When showRecordId:false, we see the $recordId field that we set.

      MongoDB Enterprise rs:PRIMARY> db.newcoll.insert({$recordId: 12, a: 1})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise rs:PRIMARY> db.newcoll.find()
      { "_id" : ObjectId("65c27f064bb7df438ffb4d1c"), "$recordId" : 12, "a" : 1 }
      MongoDB Enterprise rs:PRIMARY> db.newcoll.find().showRecordId()
      { "_id" : ObjectId("65c27f064bb7df438ffb4d1c"), "$recordId" : NumberLong(1), "a" : 1 }
      

      The document exists properly on disk. And it exists in properly in the oplog too:

      MongoDB Enterprise rs:PRIMARY> use local
      switched to db local
      MongoDB Enterprise rs:PRIMARY> db.oplog.rs.find({ns: /newcoll/}).pretty()
      {
      	"op" : "i",
      	"ns" : "test.newcoll",
      	"ui" : UUID("4c079773-1ac9-44e9-9ee5-5d2b5f85ce7b"),
      	"o" : {
      		"_id" : ObjectId("65c27f064bb7df438ffb4d1c"),
      		"$recordId" : 12,
      		"a" : 1
      	},
      	"o2" : {
      		"_id" : ObjectId("65c27f064bb7df438ffb4d1c")
      	},
      	"ts" : Timestamp(1707245318, 2),
      	"t" : NumberLong(1),
      	"v" : NumberLong(2),
      	"wall" : ISODate("2024-02-06T18:48:38.177Z")
      }
      

      So it seems like in the query layer, the field is being swapped out with the recordId when showRecordId:true.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: