-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 4.2.0, 3.6.14, 3.4.23
-
Component/s: mongorestore
-
None
-
Not Needed
-
(copied to CRM)
Older driver versions allowed invalid index fields. When one of these invalid index fields exists, it gets dumped by mongodump and then upon mongorestore, the process encounters a "The field 'XXX' is not valid for an index specification" error. For example:
2019-09-27T04:03:10.421-0700 Failed: testdb.food: error creating indexes for testdb.food: createIndex error: (InvalidIndexSpecificationOption) The field 'safe' is not valid for an index specification. Specification: { key: { a: 1.0 }, name: "a_1", ns: "testdb.food", safe: true }
Possible workarounds:
- Delete and re-create the index. Not a great option since dropping the index to re-create it could significantly affect performance.
- Perform the mongorestore with the "–noIndexRestore" option
Reproduction steps:
- On a deployment running 3.2 or earlier, create an index with an invalid option using the mongo shell. A common invalid option previously introduced by one of the drivers was "safe".
- Upgrade it to 3.4
- Take a mongodump (any version, including 4.2.0)
- Run mongorestore (any version, including 4.2.0)
Example of creating an index with an invalid option (on deployment running 3.2.23):
> db.foo.insert({a:1}) WriteResult({ "nInserted" : 1 }) > db.foo.drop() true > db.foo.insert({"a":1}) WriteResult({ "nInserted" : 1 }) > db.food.createIndex({"a":1},{"safe": true}) { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 }
- is depended on by
-
TOOLS-2384 Backport 'TOOLS-2379 mongodump/mongorestore error if source database has an invalid index option'
- Closed