[SERVER-43575] Duplicate index because of deprecation of background Created: 23/Sep/19 Updated: 27/Oct/23 Resolved: 24/Sep/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Ben Rotz | Assignee: | Carl Champain (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | Example: runing db.test.createIndex({'a.b': 1}, {background: true}); Index existing in 4.0
Running db.test.createIndex({'a.b': 1}, {background: true}); is valid, and produces "all indexes already exist"
Same index, running db.test.createIndex({'a.b': 1}, {background: true}); in mongo 4.2 produces "Index with name: a.b_1 already exists with a different name"
Note the name using a period instead of an underscore |
||||||||
| Participants: | |||||||||
| Description |
|
After upgrading to mongo 4.2 and running an "install" script on an application, I started getting some errors in regards to "Index with name: INDEX_NAME already exists with a different name" The problem appears to be that related to index names (at some point in mongo's past, automatic index naming used an underscore to delineate field names, for example "a_b_1" instead of "a.b_1" for an index created on {'a.b': 1} and the background flag.
This isn't a big deal to me, I will just manually recreate indexes, but I did think it was a problem worth mentioning in case it ties to something else.
|
| Comments |
| Comment by Carl Champain (Inactive) [ 24/Sep/19 ] | |||||||||||
|
Hi ben@ethika.com, Thanks for providing more details. I was able to successfully recreate your example. As you pointed out, this error is returned when an index is not created because another index already exists with the same keys but with a different name; this is an intended change brought by I will close this ticket as this is not a bug. Kind regards, | |||||||||||
| Comment by Ben Rotz [ 23/Sep/19 ] | |||||||||||
|
I see this has nothing to do with "background", it's actually just throwing an error when the name is different now (it did not use to do this). The following also produce the same outcome:
My apologies for making it out to seem like background was the culprit, it is not. It is a change in how mongo errors out when creating the same index with a different name vs. just having a note. I didn't see this behavior documented anywhere, but it probably is somewhere I just haven't looked at yet. | |||||||||||
| Comment by Ben Rotz [ 23/Sep/19 ] | |||||||||||
|
If I run the following two commands in sequence:
4.0.12 gives me all indexes already exist
4.2 gives me Index with name: a.b_1 already exists with a different name
| |||||||||||
| Comment by Carl Champain (Inactive) [ 23/Sep/19 ] | |||||||||||
|
Hi ben@ethika.com, Thanks for the report. I've followed your example, but if I run
I get "all indexes already exist" in both cases. Plus, the output of
is the same for 4.0 and 4.2:
It seems that you are running into this problem because you have old indexes - ones that use an underscore to define field names - but your example mentions 4.0 and I wasn't able to see this behavior. Kind regards, |