leaf snowflake 是否真正解决了由时钟回拨引起的重复 ID 问题?
For example, the background thread will synchronize the current time of the machine with ZK every 3 seconds. Suppose it is the 9th second, and the background thread has just synchronized the time with ZK. Then, after 2 seconds, an ID is sent out. At this time, the machine restarts and the clock is reset, resetting by 1 second. When the leaf snowflake starts, it compares the current machine time with the last registration time in ZK. If it is less than the last registration time, it can be determined that the reset has been triggered. Since this reset only resets by 1 second, that is, the current machine time is the 10th second, which is greater than the 9th second, so the startup can be normal. Then, the 10th second will continue to be used for ID distribution. Now the problem is that before the restart, 2 seconds of ID have actually been distributed, which means that all the IDs before the 11th second have been distributed. However, after the restart, ID distribution starts from the 10th second, and this will cause the ID to be distributed repeatedly.
内容来源: Meituan-Dianping/Leaf