-
Notifications
You must be signed in to change notification settings - Fork 84
objectid: After 2038, object id generation will fail. #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
can you give me input data? |
I just change the system time to 2100, then this bug ouccr. dateWed Jan 6 09:46:16 JST 2100 pythonPython 2.7.5 (default, Aug 29 2016, 10:12:21)
|
The max of int is 2147483647(2^31-1) and the seconds of 2038/1/19 03:14:07 UTC are 2147483647, after this time, the int is out of range. |
We may use a unsigned long int(struct.pack(">L", int(time.time()))) to describe the time, but the object id may use extra 4 bytes. |
The only "correct" way to correct this, preserving the lexicographical sort order of the IDs, is to expand the size of that field as we more closely approach the limit. This would likely require re-encoding of every ID present in the dataset, as variable width fields will not sort correctly. If you're going to expand, go whole-hog. Bump from 32- to 64-bit and have 54 zeptoseconds (~585 billion years) to worry about the next precision hike. |
|
The code as follows:
def __generate(self):
"""Generate a new value for this ObjectId.
"""
Error message as follows:
packages/bson/objectid.py", line 170, in __generate
oid = struct.pack(">i", int(time.time()))
error: 'i' format requires -2147483648 <= number <= 2147483647
The text was updated successfully, but these errors were encountered: