Index creation fails after creating the first background index
See original GitHub issueIndex creation fails with error MongoError: cannot add index with a background operation in progress
for all but the first index if there are many indexes defined for a schema and the indexes take some time to create.
Run https://github.com/hvrauhal/mongoosebug to reproduce.
This is related to issue #1059
Issue Analytics
- State:
- Created 11 years ago
- Comments:11
Top Results From Across the Web
Strange error on index creation - N1QL - Couchbase Forums
I have a cluster with two nodes. I want to create an index on one of the nodes using: CREATE INDEX `geo_nearest_location` ON...
Read more >Index Creation - Amazon DocumentDB - AWS Documentation
Background index builds in Amazon DocumentDB do not start until all queries on the primary instance that started before the index build was...
Read more >What happens when Index creation in MongoDB which is ...
So this means, background or foreground, an index key too long will cause the creation to fail. However, no matter how you create...
Read more >Index Builds on Populated Collections — MongoDB Manual
Background index builds were slower and had less efficient results, but allowed read-write access to the database and its collections during the build...
Read more >Background Index Creation on SQL Server
In your particular case, it seems index creation was being rolled forward by the database startup/crash recovery process.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ah ok, reproduced it. thanks
Currently MongoDB does not permit multiple background indexes running. I’ve confirmed executing these indexes one-by-one fixes the problem. The commit will land soon.
If this is a production setup, its best to disable auto index creation in production due to the potential performance impact. You can grab the list of indexes from your Models schema like so:
var indexes = YourModel.schema.indexes()
, then follow the recommendations for creating them in production.FYI: in my testing MongoDB 2.4 doesn’t have this limitation.
Related MongoDB tickets: https://jira.mongodb.org/browse/SERVER-2771 https://jira.mongodb.org/browse/SERVER-2374