[SERVER-8095] Update with positional operator does not update index Created: 07/Jan/13 Updated: 07/Mar/14 Resolved: 10/Jan/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance, Write Ops |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dave Longley | Assignee: | Thomas Rueckstiess |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | MongoDB shell version: 2.2.2 ]}); ); ] } , {$set: {'array.$': {'a': 'c'}}}); ); ] } ); ); ] } , {$set: {'array.$': {'a': 'b'}}}); ); > db.test.find( {'array.a': 'b'}); ] } |
||||||||
| Participants: | |||||||||
| Description |
|
When performing an update using the positional operator on a field that contains an indexed subfield, the index is not updated. The result is that the document cannot be found via the index after the update. If you drop the index, the document can be found. |
| Comments |
| Comment by David I. Lehn [ 07/Jan/13 ] | |||||||||||||
|
In case anyone else comes across this bug, a workaround is to use a bogus subproperty such as 'data' just to store your real object:
| |||||||||||||
| Comment by Thomas Rueckstiess [ 07/Jan/13 ] | |||||||||||||
|
Thanks, Dave and David, for reporting this bug and the jstest. I'm currently trying to confirm that this is the same as | |||||||||||||
| Comment by Thomas Rueckstiess [ 07/Jan/13 ] | |||||||||||||
|
This issue is very similar (if not the same) to | |||||||||||||
| Comment by David I. Lehn [ 07/Jan/13 ] | |||||||||||||
|
I wrote a couple tests similar to mongo/jstests/update_arraymatch#.js to help debug this. 2.0.7 and 2.2.2 indexing works fine in some cases when using the positional operator:
However, it fails when you $set a whole object instead of just a property. The index is not updated, the new data can't be found, and you will get the new data when you query for the old data! Below is the failing test case with a check to also make sure old data is not found. I can make a pull request for this and the others if needed.
| |||||||||||||
| Comment by Dave Longley [ 07/Jan/13 ] | |||||||||||||
|
May be related to: https://jira.mongodb.org/browse/SERVER-5067 |