[SERVER-16045] null value in mapReduce results Created: 10/Nov/14 Updated: 10/Jan/15 Resolved: 10/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | MapReduce |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dmitry Poklonskiy | Assignee: | Ramon Fernandez Marina |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | OS X |
| Participants: |
| Description |
|
db version v2.6.4 I have ~100 entries (dump in attach) in my collection and try to do mapReduce on it with the following command
"_quadKey" field which is used for grouping in Map function is a string of base-4 numbers that looks like "33100321300223132221023" As a result of this command i got 5 reduce calls instead of 4 (see stat)
Also I have noticed that group where I've got "null" depends on index
If i drop this index I've got this issue in first "0" group
|
| Comments |
| Comment by Ramon Fernandez Marina [ 10/Jan/15 ] | |||||||||||||||||||||
|
dimik, after some investigation it seems that your reduce function does not meet the necessary requirements. Note specifically the following paragraph:
The null value appears because the reduce function is called a second time (and you're seeing 5 reduce calls instead of the 4 you expect), and you add it._id to the result – but that it value is not a document from your collection but the previous result of calling the reduce function with the same key so it._id is null. This also explains the fact that you don't see all the _quadKey entries you're expecting, as in this second call to reduce you dismiss the results from previous calls. If I modify your reduce function to detect this case then everything works as expected:
Please check the rest of the requirements for the reduce function and modify your code accordingly. Regards, | |||||||||||||||||||||
| Comment by Ramon Fernandez Marina [ 10/Jan/15 ] | |||||||||||||||||||||
|
Hi dimik, apologies for the late reply. Thanks for the data and the reproducer, we can observe the same behavior you describe and we're investigating. | |||||||||||||||||||||
| Comment by Dmitry Poklonskiy [ 10/Nov/14 ] | |||||||||||||||||||||
|
Forgot to say, I called mapReduce command from mongo-shell |