Closed stefanth closed 12 years ago
You appear to be right about this. Fix upcoming.
the id is Duplicate while hight concurrent,but i don't konw the reason,pleanse checked
this is my product config new SnowflakeConfig { serverPort = 7610 datacenterId = 0 workerIdMap = Map(0 -> InetAddress.getLocalHost.getHostName) // workerIdMap = Map(1 -> "cmg1.chamago.com") workerIdZkPath = "/snowflake-servers" skipSanityChecks = true startupSleepMs = 10000 thriftServerThreads = 10
zookeeperClientConfig = new ZookeeperClientConfig { hostList = "cmg1.chamago.com:2181,cmg2.chamago.com:2181,cmg3.chamago.com:2181" }
reporterConfig = new ReporterConfig { scribeCategory = "snowflake" scribeHost = "localhost" scribePort = 1463 scribeSocketTimeout = 5000 flushQueueLimit = 100000 }
admin = new AdminServiceConfig { httpPort = 9991 }
loggers = new LoggerConfig { handlers = new FileHandlerConfig { filename = "snowflake2.log" level = Logger.TRACE } }
} only one worker id,i implemented in java ,no Duplicate
sorry me implement in java also display Duplicate,my god
This was fixed a long time ago.
If the clock moves backwards the sequence is reset to 0 before raising InvalidSystemClock. When the time moves again forward to lastTimestamp then the IdWorker will generate duplicate ids for that millisecond (from 0 up to the old value of the sequence variable, depending on how many calls are made when that millisecond is revisited). The correct way is probably to do the "timestamp < lastTimestamp" check before the "lastTimestamp == timestamp" check.