Info
MongoDB 4.2 updated the mongo shell helper methods for createIndex(es) in SERVER-39760 adding a third parameter for commitQuorum.
Though the option to createIndexes wasn't added/documented until 4.4, according to SERVER-47193 the createIndexes command should accept commitQuorum as a no-op however it doesn't appear to work:
MongoDB shell version v4.2.20
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
MongoDB server version: 4.2.20
MongoDB Enterprise > db.foo.createIndex({ "bar": 1 }, { background: true }, { name: "baz" });
{
"ok" : 0,
"errmsg" : "Invalid field specified for createIndexes command: commitQuorum",
"code" : 2,
"codeName" : "BadValue"
}
As 4.2 users would only encounter this if they accidentally passed 3 arguments to createIndexes the workaround is to fix their command:
MongoDB Enterprise > db.foo.createIndex({ "bar": 1 }, { background: true, name: "baz" });
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
Tested on 4.2.20-ent.
Top User Comments
connie.chen commented on Tue, 12 Jul 2022 15:54:32 +0000:
Closing this as we do not plan to make any changes to the shell in 4.2, this also seems to cause minimal impact. We acknowledge the error message can be confusing, but this scenario doesn't exist in 4.4+ versions.