[SERVER-13875] ensureIndex of 2dsphere index breaks after upgrading to 2.6 (with the new createIndex command) Created: 08/May/14 Updated: 19/Sep/15 Resolved: 15/May/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 2.6.1 |
| Fix Version/s: | 2.6.11, 3.0.4, 3.1.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Derick Rethans | Assignee: | J Rassi |
| Resolution: | Done | Votes: | 0 |
| Labels: | ET | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Minor Change | ||||||||
| Operating System: | ALL | ||||||||
| Backport Completed: | |||||||||
| Participants: | |||||||||
| Description |
|
On a collection, I have an existing 2dsphere index (created while still using MongoDB 2.4.x):
I have some code that adds stuff from foursquare, and this script runs PHP's ensureIndex() to create the 2dsphere index in case it doesn't exist. On the shell, the equivalant is:
However, that generates:
But I am not setting any new options. However, when I create a 2dsphere index on a different field (loc instead of l):
Then it creates this index:
(Note the extra "2dsphereIndexVersion" : 2). When I then run the createIndex again, I get (correctly):
It looks like it breaks over the extra 2dsphereIndexVersion "option", but as user I have no influence over that not being set. |
| Comments |
| Comment by Githook User [ 19/May/15 ] |
|
Author: {u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}Message: (cherry picked from commit 20e130aceda766c646d123d8a853ea5aabbeab26) |
| Comment by Githook User [ 15/May/15 ] |
|
Author: {u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}Message: (cherry picked from commit 20e130aceda766c646d123d8a853ea5aabbeab26) |
| Comment by Githook User [ 15/May/15 ] |
|
Author: {u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}Message: |
| Comment by Alexander Komyagin [ 13/May/15 ] |
|
rassi@10gen.com thanks for the clarification. I somehow missed it - sorry! |
| Comment by J Rassi [ 13/May/15 ] |
|
alex.komyagin@10gen.com: that's scenario #5 from my list above. |
| Comment by Alexander Komyagin [ 13/May/15 ] |
|
There is another scenario that was pointed out by one of our customers:
In other words, the problem might be deeper - we just shouldn't have implicit versions |
| Comment by J Rassi [ 13/May/15 ] |
|
I propose changing the behavior of ensureIndex() to succeed as a no-op with "index already exists" if an index already exists on the same key pattern and differs only in index plugin version (2dsphereIndexVersion or textIndexVersion), rather than fail with "index options conflict". It seems to me that this will better conform to user expectations. To illustrate, see how creating an index on a given 2dsphere key pattern 'kp' would work in the following scenarios (the behavior in scenarios #1/#3/#4 would remain unchanged, and the behavior in #2/#5 would change):
|
| Comment by Derick Rethans [ 08/May/14 ] |
|
I am not specifying any other options that I already did, so at least the error message is wrong. I would also certainly not expect that my already running scripts would just stop working. The ensureIndex match should be done before the server adds any options of its own perhaps. I also can not find this in http://docs.mongodb.org/master/release-notes/2.6-compatibility as an incompatibility. |
| Comment by Greg Studer [ 08/May/14 ] |
|
This is basically WAD - the index defaults needed to change for new indexes. It may be trivial to make "2dsphereIndexVersion" : 1 in v2.6 and above basically unset the field completely, which is currently correctly handled. Keeping ticket open to check. > It looks like it breaks over the extra 2dsphereIndexVersion "option", but as user I have no influence over that not being set. The workaround is to reindex in v2.6 or, if you're testing during an upgrade, you can manually set '2dsphereIndexVersion' : 1 when creating the index in v2.4. |