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

Collection UUID mismatch error is not prioritized when we use the name of a view

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v6.0
    • Execution Team 2022-10-31

      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)
      }
      

            Assignee:
            gregory.noma@mongodb.com Gregory Noma
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: