|
In 2.6 the first index would succeed and the later builds would be skipped since the index now exists. In master this fails because the code to skip existing indexes happens before we build any indexes, so we attempt to build both indexes and fail:
db = db.getSiblingDB("createIndexes");
|
db.dropDatabase();
|
db.test.runCommand( "createIndexes", { indexes : [ { name : "x_1", key : { "x" : 1 }, ns: "createIndexes.test" },
|
{ name : "x_1", key : { "x" : 1 }, ns: "createIndexes.test" } ] } );
|
|
// 2.6.3 result:
|
{
|
"createdCollectionAutomatically" : true,
|
"numIndexesBefore" : 1,
|
"note" : "index already exists",
|
"numIndexesAfter" : 2,
|
"ok" : 1
|
}
|
// 2.7 Nightly Result
|
{
|
"createdCollectionAutomatically" : true,
|
"numIndexesBefore" : 1,
|
"errmsg" : "exception: x_1",
|
"code" : 68, // IndexAlreadyExists
|
"ok" : 0
|
}
|
|