wsm12138 opened a new issue, #18829: URL: https://github.com/apache/shardingsphere/issues/18829
## Bug Report **For English only**, other languages will not accept. Before report a bug, make sure you have: - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues). - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview). Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will **close it**. Please answer these questions before submitting your issue. Thanks! ### Which version of ShardingSphere did you use? master ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy? ShardingSphere-Proxy ### Expected behavior no error ### Actual behavior ```[INFO ] 2022-07-04 18:53:05.014 [MySQL.MGR-sharding_db-replica_ds_Worker-1] o.a.s.d.a.DatabaseDiscoveryEngine - Replica data source has changed, notification scaling to restart job. The databaseName name is : sharding_db, groupName is : replica_ds, dataSourceName is : ds_1 [ERROR] 2022-07-04 18:53:05.356 [Curator-SafeNotifyService-0] c.g.common.eventbus.EventBus.default - Exception thrown by subscriber method renew(org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.PrimaryStateChangedEvent) on subscriber org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator@1b3a9ef4 when dispatching event: org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.PrimaryStateChangedEvent@6675c82a java.lang.NullPointerException: null at org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator.renew(ClusterContextManagerCoordinator.java:197) 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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:87) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:144) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:72) at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:67) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:108) at com.google.common.eventbus.EventBus.post(EventBus.java:212) at java.util.Optional.ifPresent(Optional.java:159) at org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory.lambda$watch$0(GovernanceWatcherFactory.java:55) at org.apache.shardingsphere.mode.repository.cluster.zookeeper.CuratorZookeeperRepository.lambda$watch$0(CuratorZookeeperRepository.java:240) at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.sendEvent(TreeCacheListenerWrapper.java:71) at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.event(TreeCacheListenerWrapper.java:42) at org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.lambda$event$0(CuratorCacheListenerBuilderImpl.java:149) at java.util.ArrayList.forEach(ArrayList.java:1259) at org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.event(CuratorCacheListenerBuilderImpl.java:149) at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$putStorage$7(CuratorCacheImpl.java:279) at org.apache.curator.framework.listen.MappingListenerManager.lambda$forEach$0(MappingListenerManager.java:92) at org.apache.curator.framework.listen.MappingListenerManager.forEach(MappingListenerManager.java:89) at org.apache.curator.framework.listen.StandardListenerManager.forEach(StandardListenerManager.java:89) at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$callListeners$10(CuratorCacheImpl.java:293) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) [ERROR] 2022-07-04 18:53:05.357 [Curator-SafeNotifyService-0] c.g.common.eventbus.EventBus.default - Exception thrown by subscriber method renew(org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.StorageNodeChangedEvent) on subscriber org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator@1b3a9ef4 when dispatching event: org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.event.StorageNodeChangedEvent@3a32cb5f java.lang.NullPointerException: null at org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator.renew(ClusterContextManagerCoordinator.java:184) at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:87) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:144) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:72) at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:67) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:108) at com.google.common.eventbus.EventBus.post(EventBus.java:212) at java.util.Optional.ifPresent(Optional.java:159) at org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory.lambda$watch$0(GovernanceWatcherFactory.java:55) at org.apache.shardingsphere.mode.repository.cluster.zookeeper.CuratorZookeeperRepository.lambda$watch$0(CuratorZookeeperRepository.java:240) at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.sendEvent(TreeCacheListenerWrapper.java:71) at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.event(TreeCacheListenerWrapper.java:42) at org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.lambda$event$0(CuratorCacheListenerBuilderImpl.java:149) at java.util.ArrayList.forEach(ArrayList.java:1259) at org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.event(CuratorCacheListenerBuilderImpl.java:149) at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$putStorage$7(CuratorCacheImpl.java:279) at org.apache.curator.framework.listen.MappingListenerManager.lambda$forEach$0(MappingListenerManager.java:92) at org.apache.curator.framework.listen.MappingListenerManager.forEach(MappingListenerManager.java:89) at org.apache.curator.framework.listen.StandardListenerManager.forEach(StandardListenerManager.java:89) at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$callListeners$10(CuratorCacheImpl.java:293) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) [INFO ] 2022-07-04 18:53:10.107 [MySQL.MGR-sharding_db-replica_ds_Worker-1] o.a.s.d.a.DatabaseDiscoveryEngine - Replica data source has changed, notification scaling to restart job. The databaseName name is : sharding_db, groupName is : replica_ds, dataSourceName is : ds_1 ``` ### Reason analyze (If you can) can't ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc. #### 1. buidl proxy cluster ##### server.yaml ``` mode: type: Cluster repository: type: ZooKeeper props: namespace: governance_ds server-lists: localhost:2181 retryIntervalMilliseconds: 500 timeToLiveSeconds: 60 maxRetries: 3 operationTimeoutMilliseconds: 500 overwrite: true rules: - !AUTHORITY users: - user: root@% password: root - user: sharding password: sharding privilege: type: ALL_PERMITTED ``` ##### config-sharding.yaml ``` databaseName: sharding_db dataSources: ds_0: url: jdbc:mysql://127.0.0.1:3306/ds_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root maxPoolSize: 40 minPoolSize: 1 ds_1: url: jdbc:mysql://127.0.0.1:3306/ds_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root maxPoolSize: 40 minPoolSize: 1 ds_2: url: jdbc:mysql://127.0.0.1:3306/ds_2?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root maxPoolSize: 40 minPoolSize: 1 ds_3: url: jdbc:mysql://127.0.0.1:3306/ds_3?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root maxPoolSize: 5 minPoolSize: 1 rules: - !SHARDING autoTables: t_order: actualDataSources: source_readwrite keyGenerateStrategy: column: order_id keyGeneratorName: t_order_snowflake logicTable: t_order shardingStrategy: standard: shardingAlgorithmName: t_order_hash_mod shardingColumn: order_id shardingAlgorithms: t_order_inline: props: algorithm-expression: t_order_${order_id % 2} type: INLINE t_order_hash_mod: props: sharding-count: '6' type: hash_mod keyGenerators: snowflake: type: SNOWFLAKE scalingName: default_scaling scaling: default_scaling: input: workerThread: 40 batchSize: 1000 output: workerThread: 40 batchSize: 1000 streamChannel: type: MEMORY props: block-queue-size: 10000 dataConsistencyChecker: type: DATA_MATCH props: chunk-size: 1000 - !READWRITE_SPLITTING dataSources: source_readwrite: type: Static props: write-data-source-name: ds_0 read-data-source-names: ds_1 loadBalancerName: random target_readwrite: type: Static props: write-data-source-name: ds_2 read-data-source-names: ds_3 loadBalancerName: random loadBalancers: random: type: RANDOM ``` #### 3. Proxy exectue sql ``` use sharding_db CREATE TABLE t_order (order_id bigint NOT NULL, user_id int DEFAULT NULL, status varchar(50) DEFAULT NULL, t_numeric numeric(10,2) DEFAULT NULL, PRIMARY KEY (order_id)); ALTER SHARDING TABLE RULE t_order(RESOURCES(source_readwrite,target_readwrite),SHARDING_COLUMN=order_id,TYPE(NAME=hash_mod,PROPERTIES('sharding-count'=6)),KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))); ``` stdout.log ——> java.lang.NullPointerException: null ### 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
