[SERVER-50073] Error message when creating a mixed hashed/not hashed index does not state the problem Created: 03/Aug/20  Updated: 29/Oct/23  Resolved: 12/Feb/21

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 4.0.20, 4.2.8
Fix Version/s: 4.2.13, 4.0.24

Type: Bug Priority: Minor - P4
Reporter: Oleg Pudeyev (Inactive) Assignee: Dan Larkin-York
Resolution: Fixed Votes: 0
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
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
Participants:

 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



 Comments   
Comment by Githook User [ 12/Feb/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-50073 Error message when creating a mixed hashed/not hashed index should state the problem
Branch: v4.2
https://github.com/mongodb/mongo/commit/ecbb91d31416fc9a68d896ea255f5494ca2a54d4

Comment by Githook User [ 11/Feb/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: Revert "SERVER-50073 Error message when creating a mixed hashed/not hashed index should state the problem"

This reverts commit 2084b2b2baba4028d7cbc0cb3dc22222e25bb6f8.
Branch: v4.2
https://github.com/mongodb/mongo/commit/1a09a40b8e42f9b682d602e168699327607da218

Comment by Githook User [ 11/Feb/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: Revert "SERVER-50073 Error message when creating a mixed hashed/not hashed index should state the problem"

This reverts commit b73f99b8a8514504cb91ed0060e155f8be689b45.
Branch: v4.0
https://github.com/mongodb/mongo/commit/f3cdc0e6d3bcd4c3780d584f3f6759f8cea51616

Comment by Githook User [ 11/Feb/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-50073 Error message when creating a mixed hashed/not hashed index should state the problem
Branch: v4.2
https://github.com/mongodb/mongo/commit/2084b2b2baba4028d7cbc0cb3dc22222e25bb6f8

Comment by Githook User [ 11/Feb/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-50073 Error message when creating a mixed hashed/not hashed index should state the problem
Branch: v4.0
https://github.com/mongodb/mongo/commit/b73f99b8a8514504cb91ed0060e155f8be689b45

Generated at Thu Feb 08 05:21:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.