Hacker News new | ask | show | jobs
by starfox64_ 1125 days ago
I've had a similar issue with MongoDB's ObjectIDs. They are generated using a combination of process id, UNIX timestamp and a counter that is randomly initialized during process creation. The issue when docker comes into the mix is that the root process id of every container is 1 so a decent chunk of entropy is removed from the ObjectID. Add to that the fact that the timestamp doesn't have millisecond resolution, the only thing saving you is praying the counter of any of your processes never overlaps during the same second.

It's unlikely to happen but still possible and it has brought down some of our parallel worker pool because once you have a collision, you are bound to keep generating the same id sequence until you restart your whole process to randomize the counter again.

1 comments

MongoDB eventually switched away from doing that and now just generates random numbers for the pid and machineid fields of ObjectIDs. The timestamp is still there because people rely on being able to sort on that (which is a bad idea for various reasons), but it's at least 24 bytes of randomness now.
When did this change? Last I checked the PHP driver still relied on the pid.