Some devs have been working on an issue with our DB. Whilst not finding it yet, they have suggested some changes we could make to avoid the error occurring. So this task is to find work arounds which achieve the same functionality but in different ways.
Here’s the relevant discussion copy/pasted:
Removing listIndexes calls from our codebase
A global search oflistIndexes
in your project after opening it in gitpod yields no results (though it may be called byensureIndex
). This is a total shot in the dark, but make sure you’re not using the admin database for your application - i.e. that the database name at the end of your mongodb connection string is not “admin”.
- Could this
_ensureIndex
be the problem? I think that may be calling intolistIndexes
here: node-mongodb-native/db_ops.js at 2b18411d2f57e06d11262d5a308c56a9f561789e · mongodb/node-mongodb-native · GitHub . IIRC,ensureIndex
is deprecated, and you should usecreateIndex
instead. I’m not familiar with meteor, so I’m not exactly sure what that code looks like, but the README shows how to access the underlying MongoDB driver directly: meteor/packages/mongo at devel · meteor/meteor · GitHub. Hope that helps!
I know MongoDB and NodeJS reasonably well but React and Meteor not at all. That said, it looks like this line is what is interrogating the indexes (calling
listIndexes
on the MongoDB collection):
https://github.com/focallocal/fl-maps/blob/ef5a4e184b0a30a6cc5fe3e620a01f27aa324c23/imports/both/collections/events/index.js#L572
The line is: Events._ensureIndex({ ‘address.location’: ‘2dsphere’ })
I would suggest commenting out that line to see if it resolves the issue. Obviously it’s creating an index that is required so searching byaddress.location
in theEvents
collection may be slow - depending on the number of records in the collection - until you can find a proper fix.
Following up on some of the feedback you’ve received, it’s clear that your code is calling ensureIndex (https://github.com/focallocal/fl-maps/blob/ea6c71a1a1d24440f1be493d88a9c4e681203708/imports/both/collections/events/index.js#L572 ). From the code that was linked, the ensureIndex function (https://github.com/mongodb/node-mongodb-native/blob/2b18411d2f57e06d11262d5a308c56a9f561789e/lib/operations/db_ops.js#L132) calls indexInformation (https://github.com/mongodb/node-mongodb-native/blob/2b18411d2f57e06d11262d5a308c56a9f561789e/lib/operations/db_ops.js#L279), which in turn calls listIndexes (https://github.com/mongodb/node-mongodb-native/blob/2b18411d2f57e06d11262d5a308c56a9f561789e/lib/operations/db_ops.js#L305) which appears to be where the problem is triggered.