[SERVER-9931] hashed shard keys do not appear to handle decimal values Created: 13/Jun/13 Updated: 10/Dec/14 Resolved: 27/Aug/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 2.4.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Edouard Servan-Schreiber | Assignee: | Greg Studer |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Operating System: | ALL | ||||||||||||
| Steps To Reproduce: | // Set up a sharding test. ); } ); function insertData(db, colName, num, w) { // |
||||||||||||
| Participants: | |||||||||||||
| Description |
|
Tried using a hashed shard key after defining an empty collection as hashed sharded. All decimal values between 0 and 1 were routed to the same shard. |
| Comments |
| Comment by Greg Studer [ 27/Aug/14 ] |
|
We don't recommend using floating-point values as shard keys - arithmetic can cause surprising results. The current behavior is built into the hashed indexes and is not currently changeable - though a simple workaround is to transform the double value into another type if small decimal increments really are being used as unique _ids. |
| Comment by Spencer Brody (Inactive) [ 13/Jun/13 ] |
|
This is a known issue, see the warning on this page: http://docs.mongodb.org/manual/tutorial/shard-collection-with-a-hashed-shard-key/ |