-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: JavaScript, Shell
-
None
-
Fully Compatible
-
ALL
It should test getLastError == null rather than ""
> db.asdf.ensureIndex function (keys, options) { var name = this._indexSpec(keys, options).name; this._indexCache = this._indexCache || {}; if (this._indexCache[name]) { return; } this.createIndex(keys, options); if (this.getDB().getLastError() == "") { this._indexCache[name] = true; } } > db.asdf.ensureIndex({a:1}); db.getLastError() null > db.asdf.ensureIndex({a:1}); db.getLastError() == "" false
Note that if we fix this we need to make sure that the _indexCache does not persist across calls to db.eval() as the cache won't be invalidated at the necessary times.
Also, it may be best to just not cache ensureIndex in the shell. If someone runs a script that drops an index, they would expect ensureIndex in an admin shell to rebuild it, even if the shell had been open a while.
- is related to
-
SERVER-15693 DBClientWithCommands should not cache ensureIndex calls
-
- Closed
-