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

Id collision possibility #105

Open
gregorygauthier opened this issue Sep 19, 2017 · 2 comments
Open

Id collision possibility #105

gregorygauthier opened this issue Sep 19, 2017 · 2 comments

Comments

@gregorygauthier
Copy link

gregorygauthier commented Sep 19, 2017

From what I understand of the code, the generation algorithm works by taking the following data in order and encoding it:

  1. The version
  2. The cluster worker id
  3. The counter
  4. The timestamp (number of seconds since the epoch defined in the code)

This creates a possibility of a collision between the following, assuming that the random numbers line up correctly:

  1. An id generated with counter a and timestamp bcde
  2. An id generated with no counter and timestamp bcdea
@cesni
Copy link

cesni commented Nov 24, 2017

so, you think it's recommended to have 'short-id' like my database id(uniqueness,primary key) generator, with no collision or duplicates in some future.

@jmzhang
Copy link

jmzhang commented Dec 26, 2017

This is indeed a problem, for now, the epoch is set so that timestamp minus epoch encodes to a 7-byte string, and collisions might happen when the encoded time delta bumps to 8-byte. Fortunately, it will take more than 8 years to see this happen, assuming version is never updated.

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