You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/04/17 02:38:23 UTC

[GitHub] [incubator-shardingsphere] traceless opened a new issue #2219: SnowflakeShardingKeyGenerator hava a bug

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:
users@infra.apache.org


With regards,
Apache Git Services