[SERVER-70649] Collection UUID mismatch error is not prioritized when we use the name of a view Created: 17/Oct/22  Updated: 29/Oct/23  Resolved: 26/Oct/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Vishnu Kaushik Assignee: Gregory Noma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-68337 Perform collectionUUID check inside o... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0
Sprint: Execution Team 2022-10-31
Participants:

 Description   

Instead, we receive a "X is a view, not a collection" error whereas we expected to see "Collection UUID does not match that specified":

rs:PRIMARY> db.k.insert({a: 1})
WriteResult({ "nInserted" : 1 })
rs:PRIMARY> db.createView("myview1", "k", [])
{
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1666040411, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1666040411, 1)
}
rs:PRIMARY> db.getCollectionInfos()
[
	{
		"name" : "k",
		"type" : "collection",
		"options" : {
			
		},
		"info" : {
			"readOnly" : false,
			"uuid" : UUID("57f2edab-d2a8-4a16-9362-5df638eb05c5")
		},
		"idIndex" : {
			"v" : 2,
			"key" : {
				"_id" : 1
			},
			"name" : "_id_"
		}
	},
	{
		"name" : "myview1",
		"type" : "view",
		"options" : {
			"viewOn" : "k",
			"pipeline" : [ ]
		},
		"info" : {
			"readOnly" : true
		}
	},
	{
		"name" : "system.views",
		"type" : "collection",
		"options" : {
			
		},
		"info" : {
			"readOnly" : false,
			"uuid" : UUID("56cf39fe-8489-4c86-87f0-b027c16b5fc0")
		},
		"idIndex" : {
			"v" : 2,
			"key" : {
				"_id" : 1
			},
			"name" : "_id_"
		}
	}
]
rs:PRIMARY> db.runCommand({insert: "myview1", documents: [{a: 2}, {a: 3}], collectionUUID: UUID("57f2edab-d2a8-4a16-9362-5df638eb05c5")})
{
	"n" : 0,
	"electionId" : ObjectId("7fffffff0000000000000001"),
	"opTime" : {
		"ts" : Timestamp(1666040411, 1),
		"t" : NumberLong(1)
	},
	"writeErrors" : [
		{
			"index" : 0,
			"code" : 166,
			"errmsg" : "Namespace b.myview1 is a view, not a collection"
		}
	],
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1666040411, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	},
	"operationTime" : Timestamp(1666040411, 1)
}



 Comments   
Comment by Githook User [ 26/Oct/22 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-70649 Test `CollectionUUIDMismatch` with write commands on view
Branch: master
https://github.com/mongodb/mongo/commit/57e7b1823f64d10927bed31281ae024e77be8db0

Comment by Gregory Noma [ 26/Oct/22 ]

This was fixed by SERVER-68337, so I am using this ticket to add a test case for this.

Comment by Vishnu Kaushik [ 17/Oct/22 ]

CC: gregory.noma@mongodb.com

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