question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Index creation fails after creating the first background index

See original GitHub issue

Index 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:closed
  • Created 11 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
aheckmanncommented, Feb 28, 2013

ah ok, reproduced it. thanks

0reactions
aheckmanncommented, Mar 2, 2013

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found