[SERVER-2071] mongoimport fails to import large integers Created: 08/Nov/10  Updated: 29/May/12  Resolved: 30/Nov/10

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 1.6.4
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Morten Siebuhr Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 10.04 LTS / IA-32


Operating System: ALL
Participants:

 Description   

When using mongoimport on a file w. JSON-data, it fails to import entries that contain integers over 20 chars long, citing a JSON string parsing error.

Trying to import the file:

{"some_large_int": 012345678900112233445566778899}

Leads to the following error:

mongoimport -d test -c fail_import fail-import.json
connected to: 127.0.0.1
Mon Nov  8 11:40:49 Assertion: 10340:Failure parsing JSON string near: 4556677889
0x816d811 0x81186c4 0x84b1fca 0x84b4608 0x84ac6b5 0x84b1931 0xb7570bd6 0x80f5b31 
 mongoimport(_ZN5mongo11msgassertedEiPKc+0x221) [0x816d811]
 mongoimport(_ZN5mongo8fromjsonEPKcPi+0x3b4) [0x81186c4]
 mongoimport(_ZN6Import9parseLineEPc+0x7a) [0x84b1fca]
 mongoimport(_ZN6Import3runEv+0x1a98) [0x84b4608]
 mongoimport(_ZN5mongo4Tool4mainEiPPc+0x1ce5) [0x84ac6b5]
 mongoimport(main+0x51) [0x84b1931]
 /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb7570bd6]
 mongoimport(__gxx_personality_v0+0x3f9) [0x80f5b31]
exception:Failure parsing JSON string near: 4556677889
{"some_large_int": 012345678900112233445566778899}
imported 0 objects
encountered 1 error



 Comments   
Comment by Mathias Stearn [ 30/Nov/10 ]

I think this behavior is correct given that the largest integers we store are 64-bit signed so are limited to 2^63-1 which has 19 digits.

In [3]: (2**63-1)
Out[3]: 9223372036854775807L

In [4]: len(str(2**63-1))
Out[4]: 19

Generated at Thu Feb 08 02:58:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.