[SERVER-12961] ensureIndex returns wrong error code for invalidate create index Created: 28/Feb/14  Updated: 11/Jul/16  Resolved: 03/Mar/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.6.0-rc0
Fix Version/s: 2.6.0-rc2

Type: Bug Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Steps To Reproduce:

From QA/QA-370
/**
 * bad_index_tests.js
 * Make sure that we cannot build invalid indexes with the new external sort refactor.
 *
 * Note that all of these are large enough to trigger a spill to disk.
 *
 * NOTE: for text search to be indexed you need to it to be enabled on
 * mongod startup
 */
coll = db.manyIndexType;
coll.drop();
 
//multi-key index (index on array)
//could be smaller really...
print("trying to create hashed multikey index...");
for(i=0; i<50000; i++) {
    arr = [];
    for(j=0; j<(i/100); j++) {
        arr.push(j);
    }
    coll.insert({a: arr})
}
var err = coll.ensureIndex({a : "hashed"});
assert.neq(err, undefined);
assert.eq(coll.getIndexes().length, 1);
assert.eq(err.code, 16766, "should not be able to create hashed multikey index");
coll.drop();
print("PASSED");

Participants:

 Description   

When creating a hashed index over an array we get the wrong error code.

Actual:

WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 1,
		"errmsg" : "Error: hashed indexes do not currently support array values"
	}
})

Expected:

WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 16766,
		"errmsg" : "Error: hashed indexes do not currently support array values"
	}
})



 Comments   
Comment by Mark Benvenuto [ 03/Mar/14 ]

It passes on HEAD. I will update the tests for the new WriteResult.

Comment by Eliot Horowitz (Inactive) [ 28/Feb/14 ]

I just tried this on HEAD, and the test passed.
Can you try again?

Generated at Thu Feb 08 03:30:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.