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

Error message when creating a mixed hashed/not hashed index does not state the problem

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.2, v4.0
    • Sprint:
      Execution Team 2020-09-21, Execution Team 2020-10-05, Execution Team 2020-10-19, Execution Team 2020-11-16, Execution Team 2020-11-30, Execution Team 2020-12-14, Execution Team 2020-12-28, Execution Team 2021-01-11, Execution Team 2021-01-25, Execution Team 2021-02-08, Execution Team 2021-02-22

      Description

      On 4.2 server when I try to create an index which mixes hashed and non-hashed fields I get an error message that does not state what the problem is:

      MongoDB Enterprise mongos> db.myCollection.createIndex( {"user_id": "hashed", "identifier": 1, "timestamp": 1} )
      {
      	"raw" : {
      		"shard02/localhost:14244,localhost:14245" : {
      			"ok" : 0,
      			"errmsg" : "Caught exception during index builder initialization test.myCollection (9f39f39e-b149-4a53-8a8b-84fcd8150eae): 1 provided. First index spec: { ns: \"test.myCollection\", v: 2, key: { user_id: \"hashed\", identifier: 1.0, timestamp: 1.0 }, name: \"user_id_hashed_identifier_1_timestamp_1\" }",
      			"code" : 16763,
      			"codeName" : "Location16763"
      		}
      	},
      	"code" : 16763,
      	"codeName" : "Location16763",
      	"ok" : 0,
      	"errmsg" : "Caught exception during index builder initialization test.myCollection (9f39f39e-b149-4a53-8a8b-84fcd8150eae): 1 provided. First index spec: { ns: \"test.myCollection\", v: 2, key: { user_id: \"hashed\", identifier: 1.0, timestamp: 1.0 }, name: \"user_id_hashed_identifier_1_timestamp_1\" }",
      	"operationTime" : Timestamp(1596415897, 7),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1596415897, 9),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      I expected the error message to explain the problem in some way.

      4.4 message when using more than one hashed field, for example, is clear as to what the problem is:

      ongoDB Enterprise mongos> db.myCollection.createIndex( {"user_id": "hashed", "identifier": 1, "timestamp": "hashed"} )
      {
      	"raw" : {
      		"shard01/localhost:14442,localhost:14443" : {
      			"ok" : 0,
      			"errmsg" : "Index build failed: f4ffc128-b2b7-43fb-8dc3-dca2f06616ba: Collection test.myCollection ( 04d2bde9-ca0b-4b6b-ae0b-d5e2471e5f1a ) :: caused by :: index build on empty collection failed: f4ffc128-b2b7-43fb-8dc3-dca2f06616ba :: caused by :: A maximum of one index field is allowed to be hashed but found 2 for 'key' { user_id: \"hashed\", identifier: 1.0, timestamp: \"hashed\" }",
      			"code" : 31303,
      			"codeName" : "Location31303"
      		}
      	},
      	"code" : 31303,
      	"codeName" : "Location31303",
      	"ok" : 0,
      	"errmsg" : "Index build failed: f4ffc128-b2b7-43fb-8dc3-dca2f06616ba: Collection test.myCollection ( 04d2bde9-ca0b-4b6b-ae0b-d5e2471e5f1a ) :: caused by :: index build on empty collection failed: f4ffc128-b2b7-43fb-8dc3-dca2f06616ba :: caused by :: A maximum of one index field is allowed to be hashed but found 2 for 'key' { user_id: \"hashed\", identifier: 1.0, timestamp: \"hashed\" }",
      	"operationTime" : Timestamp(1596415972, 1),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1596415974, 3),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      SO inquiry: https://stackoverflow.com/questions/63220836/mongodb-failing-to-build-index-caught-exception-during-index-builder-initializ

        Attachments

          Activity

            People

            Assignee:
            dan.larkin-york Dan Larkin-York
            Reporter:
            oleg.pudeyev Oleg Pudeyev
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: