Giter Site home page Giter Site logo

Globally Unique about bson-objectid HOT 6 CLOSED

cabinjs avatar cabinjs commented on July 19, 2024
Globally Unique

from bson-objectid.

Comments (6)

titanism avatar titanism commented on July 19, 2024 1

Please read the README description https://github.com/williamkapke/bson-objectid#bson-objectid-

https://github.com/williamkapke/bson-objectid/blob/master/objectid.js#L241-L274 versus https://github.com/mongodb/js-bson/blob/da8d8f1c0a9eaff7df6468a77e98282b8456cc3a/lib/bson/objectid.js#L151-L182

PR welcome for improvements

from bson-objectid.

sagrawal31 avatar sagrawal31 commented on July 19, 2024

We recently encountered a big flaw in our database because this library is not able to generate a globally unique id. Can't rely on it unless the author comes and comment.

from bson-objectid.

titanism avatar titanism commented on July 19, 2024

This library uses timestamps as that's the underlying mechanism.

Ref: https://github.com/williamkapke/bson-objectid/blob/master/objectid.js#L242-L252

For something unique you should use uuid or something else.

from bson-objectid.

sagrawal31 avatar sagrawal31 commented on July 19, 2024

Thanks for the clarification @titanism. Curious to know, how this is different from https://github.com/mongodb/js-bson/blob/1.0-branch/lib/bson/objectid.js?

from bson-objectid.

williamkapke avatar williamkapke commented on July 19, 2024

This library implements the same logic as Mongo's bson-objectid (see links above).

Per Mongo:

ObjectID can be considered globally unique for all practical purposes.

All globally unique methods have some possibility of duplicates- it's just a matter of making it a really small chance. Everyone needs to identify how extreme their definition of "small chance" is. For Mongo- they're saying their algorithm covers "all practical purposes."

That's certainly open for interpretation!

from bson-objectid.

sagrawal31 avatar sagrawal31 commented on July 19, 2024

Thanks, @williamkapke for jumping in and replying. You are right, Everyone needs to identify how extreme their definition of "small chance" is..

For us (where we offer a GA-like analytics SDK), we got ~950 duplicate identifiers. Upon investigation, we found that when our customers (who are using our SDK) websites when crawled by Google on daily basis, it was generating duplicate IDs very frequently that these 950 duplicates were generated just between 10th May to 6th of July.

We are assuming that this is because they must be using a hardware blueprint to launch multiple virtual devices.

from bson-objectid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.