[SERVER-86296] Existing $recordId field hidden when showRecordId:true is used Created: 06/Feb/24  Updated: 07/Feb/24

Status: Needs Scheduling
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Vishnu Kaushik Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-86310 $addFields with $meta: "recordId" doe... Backlog
Assigned Teams:
Query Execution
Operating System: ALL
Participants:

 Description   

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.


Generated at Thu Feb 08 06:59:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.