twitter-archive / snowflake

Snowflake is a network service for generating unique ID numbers at high scale with some simple guarantees.
http://twitter.com/
7.68k stars 1.13k forks source link

isn't this prone to duplicate IDs ? #24

Closed yangyangyyy closed 9 years ago

yangyangyyy commented 9 years ago

on the same server, it seems that the thrift server can be configured with multiple threads (" serverOpts.workerThreads = thriftServerThreads ")

but inside the worker, sequence is a local var. so theoretically it's possible to get duplicates. no??

bdd commented 9 years ago

Notice the synchronized block: https://github.com/twitter/snowflake/blob/snowflake-2010/src/main/scala/com/twitter/service/snowflake/IdWorker.scala#L71