You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/04/24 08:37:56 UTC
[GitHub] [shardingsphere] carlyin0801 opened a new issue, #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
carlyin0801 opened a new issue, #17055:
URL: https://github.com/apache/shardingsphere/issues/17055
Hello, the following is my code and result data, please look at the reason:
**Test code:**
object SnowFlakeUtils {
fun getId(workerId: String): Long {
val keyGenerator = SnowflakeKeyGenerateAlgorithm()
val properties = Properties()
properties.setProperty("worker-id", workerId)
keyGenerator.props = properties
keyGenerator.init()
return keyGenerator.generateKey().toString().toLong()
}
}
for (i in 1..100) {
println(SnowFlakeUtils.getId("01"))
}
**The resulting data is:**
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630224842752
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630229037056
725026630233231360
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] carlyin0801 closed issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
Posted by GitBox <gi...@apache.org>.
carlyin0801 closed issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
URL: https://github.com/apache/shardingsphere/issues/17055
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] carlyin0801 commented on issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
Posted by GitBox <gi...@apache.org>.
carlyin0801 commented on issue #17055:
URL: https://github.com/apache/shardingsphere/issues/17055#issuecomment-1107795205
Hi @zjcnb , could you help to have a look at this issue?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] TeslaCN commented on issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #17055:
URL: https://github.com/apache/shardingsphere/issues/17055#issuecomment-1109614646
Hi @carlyin0801
I noticed that your code creates instance of `SnowflakeKeyGenerateAlgorithm` every time in loop. Consider using the same instance of `SnowflakeKeyGenerateAlgorithm`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] zjcnb commented on issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #17055:
URL: https://github.com/apache/shardingsphere/issues/17055#issuecomment-1107795569
> Hi @zjcnb , could you help to have a look at this issue?
Sure, i will check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] carlyin0801 commented on issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
Posted by GitBox <gi...@apache.org>.
carlyin0801 commented on issue #17055:
URL: https://github.com/apache/shardingsphere/issues/17055#issuecomment-1112851157
ok,thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] zjcnb commented on issue #17055: The id generated by the built-in snowflake id generator of shardingsphere is duplicated, and the length is not 64 bits.
Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #17055:
URL: https://github.com/apache/shardingsphere/issues/17055#issuecomment-1107795893
> Hi @zjcnb , could you help to have a look at this issue?
Sure, i will check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org