-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Server
-
Labels:None
The documentation for geo-spatial indexes describes support for co-ordinates stored as arrays or field values. This is under the expectation that fields in documents are not reordered. However, we can sometimes re-order fields: https://jira.mongodb.org/browse/SERVER-2592 .
This can lead to broken indexes in the following scenario:
(2:31:54 PM) Chris Westin: so, if we're sometimes re-ordering fields on updates, won't that garble position dependent geo-spatial index values? e.g. {loc:{long:40, lat:73}} gets reordered (alphabetically), and the index lookup gets whacked?
(2:37:49 PM) dev@10genchat.appspotchat.com: [scott] only if you add a new field to loc
(2:38:18 PM) dev@10genchat.appspotchat.com: [scott] It only reorders at the level you make changes
(2:39:04 PM) Chris Westin: yes. then suppose i update the co-ordinates. Does it look them up by the new order, and fail to find (or find the wrong ones) in the index, and possibly update the wrong index record?
(2:39:16 PM) dev@10genchat.appspotchat.com: [scott] yes
(2:39:37 PM) Chris Westin: excellent. so current recommendation should be to use the array form of co-ordinates, until we fix that update bug
(2:39:38 PM) dev@10genchat.appspotchat.com: [scott] but only if the doc changes size
(2:39:43 PM) dev@10genchat.appspotchat.com: [scott] yes
Until SERVER-2592 is fixed, perhaps the docs should recommend only using the array form for co-ordinate storage.
- related to
-
SERVER-2592 The fields in a document are reordered (sorted alphabetically) when setting a field value
- Closed