[SERVER-2814] Server does not properly store a BSON object that contains NaN Created: 22/Mar/11 Updated: 29/Aug/11 Resolved: 03/May/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 1.8.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Ryan Nitz | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
1.6.6 and 1.8.0 |
||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
BSON objects that have NaN (and probably +/- infinity) are not stored in the database. |
| Comments |
| Comment by Ryan Nitz [ 03/May/11 ] |
|
It's actually not a pymongo bug. Some of the documents returned have periods in their keys. Thanks for tracking this down Bernie! E.g. (period is in the hostname) "connPoolStats": { , , |
| Comment by Ryan Nitz [ 03/May/11 ] |
|
Bernie is investigating pymongo... and the various versions of Python. Until recently, Python had weird double support. |
| Comment by Eliot Horowitz (Inactive) [ 03/May/11 ] |
|
Seems to be a python issue |
| Comment by Ryan Nitz [ 03/May/11 ] |
|
This seems to be working now with Java driver 2.5.3 and 1.8.1. Attached (mongo-java-double.tar.gz) is a unit test to confirm that everything works as expected between Java and Mongo. > db.testDouble.findOne(); } The BSON I'm storing via Java is being generated by Python so I'm going to see if that is the source of the problem. If that is not a problem... we can close. |
| Comment by Dwight Merriman [ 03/May/11 ] |
|
the following works...suggesting not a problem? i don't usually use the java driver if you can send me something with shell that does it would be helpful. C:\cygwin\home\dwight\mongo>mongo ) > isNaN(3) |
| Comment by Ryan Nitz [ 22/Mar/11 ] |
|
Yes... I was able to hack my way around it (see previous comment). I'll change the bug to a server bug. |
| Comment by Antoine Girbal [ 22/Mar/11 ] |
|
basically the driver seems ok. |
| Comment by Ryan Nitz [ 22/Mar/11 ] |
|
As a hack for MMS, I now serialize the data to a byte array using BSON.encode (thus the byte[] is stored in Mongo) and then for display, I use BSON.decode. No exceptions are thrown. MMS then converts the BSON to a JSON object for display in the UI (to take advantage of the org.json.JSONObject formatting options). The NaN values display properly in the converted document (as NaN). There is a problem with NaN in the Python driver too. Perhaps this is something that needs to be addressed in the product and drivers. I'm sure negative/positive infinity is also a problem. Here is the hack I put in place to work around this problem: JSONObject pingJson = null; else { pingJson = new JSONObject(); }} else { pingJson = new JSONObject(); }params.put("serverResponse", pingJson.toString(4)); |
| Comment by Antoine Girbal [ 22/Mar/11 ] |
|
looks like there is bad data in the record, some double values are "NaN". |
| Comment by Antoine Girbal [ 22/Mar/11 ] |
|
If you set a safe writeconcern, you get this exception, so server doesnt like record. $ ant run compile: run: |
| Comment by Antoine Girbal [ 22/Mar/11 ] |
|
k indeed didnt see any data but I assumes the collection got deleted during test cleanup. |
| Comment by Ryan Nitz [ 22/Mar/11 ] |
|
You see the data in the collection (test.bsonSave)? I ran it on 2.5/1.8 and it didn't insert the data. It didn't throw an exception, but there wasn't any data in the db. |
| Comment by Antoine Girbal [ 22/Mar/11 ] |
|
does it fail always? |