Skip to content
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

What happens when the 4 byte time value overflows? #69

Open
idc77 opened this issue Nov 2, 2021 · 2 comments
Open

What happens when the 4 byte time value overflows? #69

idc77 opened this issue Nov 2, 2021 · 2 comments

Comments

@idc77
Copy link

idc77 commented Nov 2, 2021

4-byte value representing the seconds since the Unix epoch,

It should be in 2038 if I'm not mistaken. It's sooner than you think. 20 years of my life went by like fingersnip this.

Shouldn't a 64bit (8byte) value be used instead?

@rs
Copy link
Owner

rs commented Nov 2, 2021

It does not matter much in terms of unicity. It will affect sorting and date extraction which could be fixed in different ways.

@dsykes16
Copy link

dsykes16 commented May 18, 2023

It's a unsigned 32-bit int, not signed (https://github.com/rs/xid/blob/master/id.go#L148). So that gives until Sunday, 7 February 2106 06:28:16 UTC by my math. I'd call 80+ years adequate.

It's much better to save 4-bytes per row now than to waste space on a problem that won't occur until next century. When solid-state storage and system memory become sufficiently cheap in the future, it's an easy fix. I'll take the 4-byte values and infra cost savings. Less space for index in memory and less space on disk. In 50 years if the code is still in use, just extend it to an 8-byte (i.e. 64-bit) time component. Keep in mind we're still closer to the date the first digital computer was invented (i.e. 1941) than we are to the date when a uint32 overflows. The chances of any code written now still being in production at that time is slim to none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants