traceless opened a new issue #2219: SnowflakeShardingKeyGenerator hava a bug 
URL: https://github.com/apache/incubator-shardingsphere/issues/2219
 
 
   ## Bug Report
   
   i have found a bug when i review code in SnowflakeShardingKeyGenerator.java 
   
   ### Which version of Sharding-Sphere do you using?
   3.1.0.M1
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
    Sharding-JDBC
   
   ## Bug in here
   ```  
       if (lastMilliseconds == currentMilliseconds) {
               if (0L == (sequence = (sequence + 1) & SEQUENCE_MASK)) {
                   currentMilliseconds = waitUntilNextTime(currentMilliseconds);
               }
           } else {
               vibrateSequenceOffset();
               sequence = sequenceOffset;
           }
   ```
   i think sequence need reset sequenceOffset when ' (sequence = (sequence + 1) 
& SEQUENCE_MASK) == 0' ;
   
   ### show you my code
   ```  
       if (lastMilliseconds == currentMilliseconds) {
               if (0L == (sequence = (sequence + 1) & SEQUENCE_MASK)) {
                   vibrateSequenceOffset();
                   sequence = sequenceOffset;
                   currentMilliseconds = waitUntilNextTime(currentMilliseconds);
               }
           } else {
               vibrateSequenceOffset();
               sequence = sequenceOffset;
           }
   ```
   Because I also need sequenceOffset in my project and  i find my code have 
different with you, so I'm not sure who's right.
   
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to