[SERVER-5974] distinct returns duplicate values Created: 31/May/12 Updated: 15/Aug/12 Resolved: 15/Jun/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 2.0.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Leonid Evdokimov | Assignee: | siddharth.singh@10gen.com |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
FreeBSD 8.2, 64-bit |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
Here is dump of mongo shell.
It really looks like bug. Here are some more strange samples:
|
| Comments |
| Comment by siddharth.singh@10gen.com [ 15/Jun/12 ] | ||
|
Hi Leonid, I am moving forward to closing this one. I created a separate | ||
| Comment by siddharth.singh@10gen.com [ 12/Jun/12 ] | ||
|
Hi Leonid, I was able to reproduce and find the root cause of the issue. Please see the attached test script. When you see [null, null] it is the shell showing two different things as one and so it is confusing. The shell displays both 'undefined' type and 'null' type as null. Internally the server does differentiate among them and identifies them as two different things. So what comes back from server is actually [undefined, null] which are distinct but shell shows them both as the same. Undefined vs Null : Note that in the attached script there is an index on users.points. When you run a distinct on users.points, the command tries to be smart and tries to use the index. The 'undefined' values come from records entered on line 5 and 6 of the script, with an empty users.points (users.points = []). The 'null' values come from records entered on line 9 and 10 of the script as they do not appear in the index. At the end, the distinct set looks like this [undefined, null, 1, 2] but appears as [null, null, 1, 2] in the mongo shell. | ||
| Comment by Leonid Evdokimov [ 04/Jun/12 ] | ||
|
Sure. > db.mondata.distinct("jclient.targets_list") | ||
| Comment by Scott Hernandez (Inactive) [ 03/Jun/12 ] | ||
|
Can you run these?
|