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 2019/08/24 09:18:42 UTC

[GitHub] [incubator-shardingsphere] m1ngyuan opened a new issue #2919: When the application restarts,LEAF_SEGMENT Distributed Primary Key Generation Not working properly in RC2

m1ngyuan opened a new issue #2919: When the application restarts,LEAF_SEGMENT Distributed Primary Key Generation Not working properly in RC2
URL: https://github.com/apache/incubator-shardingsphere/issues/2919
 
 
   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   sharding-orchestration:4.0.0-RC2
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC 
   ### Expected behavior
   When the program restarts, the primary key of LEAF_SEGMENT distribution can be generated normally.
   ### Actual behavior
   When the program restarts, the program throws a null pointer exception,
   ### SQL: insert into user (username, pwd, city_id) values (?, ?, ?)
   ### Cause: java.lang.NullPointerException
   	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
   	... 61 more
   Caused by: java.lang.NullPointerException
   	at org.apache.shardingsphere.orchestration.reg.zookeeper.curator.CuratorZookeeperRegistryCenter.tryLock(CuratorZookeeperRegistryCenter.java:306)
   	at org.apache.shardingsphere.orchestration.internal.keygen.LeafSegmentKeyGenerator.incrementCacheId(LeafSegmentKeyGenerator.java:136)
   	at org.apache.shardingsphere.orchestration.internal.keygen.LeafSegmentKeyGenerator.initLeafSegmentKeyGenerator(LeafSegmentKeyGenerator.java:95)
   	at org.apache.shardingsphere.orchestration.internal.keygen.LeafSegmentKeyGenerator.generateKey(LeafSegmentKeyGenerator.java:84)
   	at org.apache.shardingsphere.core.rule.ShardingRule.generateKey(ShardingRule.java:362)
   	at org.apache.shardingsphere.core.optimize.sharding.segment.insert.GeneratedKey.createGeneratedKey(GeneratedKey.java:117)
   	at org.apache.shardingsphere.core.optimize.sharding.segment.insert.GeneratedKey.getGenerateKey(GeneratedKey.java:72)
   	at org.apache.shardingsphere.core.optimize.sharding.engnie.dml.ShardingInsertOptimizeEngine.optimize(ShardingInsertOptimizeEngine.java:58)
   	at org.apache.shardingsphere.core.optimize.sharding.engnie.dml.ShardingInsertOptimizeEngine.optimize(ShardingInsertOptimizeEngine.java:49)
   	at org.apache.shardingsphere.core.route.router.sharding.ParsingSQLRouter.route(ParsingSQLRouter.java:72)
   	at org.apache.shardingsphere.core.route.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:66)
   	at org.apache.shardingsphere.core.PreparedQueryShardingEngine.route(PreparedQueryShardingEngine.java:60)
   	at org.apache.shardingsphere.core.BaseShardingEngine.executeRoute(BaseShardingEngine.java:86)
   	at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:70)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.shard(ShardingPreparedStatement.java:224)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:170)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
   ### Reason analyze (If you can)
   When the program restarts, Registry Center leafLock is not initialized properly,
   related code:
   
   1. [LeafSegmentKeyGenerator.java#L95](https://github.com/apache/incubator-shardingsphere/blob/dev/sharding-orchestration/sharding-orchestration-core/src/main/java/org/apache/shardingsphere/orchestration/internal/keygen/LeafSegmentKeyGenerator.java#L95) 
   2. [CuratorZookeeperRegistryCenter.java:#306](https://github.com/apache/incubator-shardingsphere/blob/dev/sharding-orchestration/sharding-orchestration-reg/sharding-orchestration-reg-zookeeper-curator/src/main/java/org/apache/shardingsphere/orchestration/reg/zookeeper/curator/CuratorZookeeperRegistryCenter.java#L306)
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   

----------------------------------------------------------------
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