Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Duplicate ids possible if clock moves backwards #6

Closed
stefanth opened this Issue Feb 23, 2012 · 5 comments

Comments

Projects
None yet
3 participants

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.

Contributor

ryanking commented Feb 24, 2012

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

Contributor

ryanking commented Nov 20, 2012

This was fixed a long time ago.

@ryanking ryanking closed this Nov 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment