zjcnb opened a new issue #14112:
URL: https://github.com/apache/shardingsphere/issues/14112


   When I start the proxy successfully, and then I start the jdbc, an exception 
occurs on the proxy side.
   
   ### Which version of ShardingSphere did you use?
   
   `master`
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ` ShardingSphere-Proxy `and `ShardingSphere-JDBC`
   
   ### Expected behavior
   
   No error message.
   
   ### Actual behavior
   
   
   ```
   Exception thrown by subscriber method 
renew(org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.RuleConfigurationsChangedEvent)
 on subscriber 
org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator@71370fec
 when dispatching event: 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.RuleConfigurationsChangedEvent@904939b
   java.lang.NullPointerException
        at 
org.apache.shardingsphere.dbdiscovery.mgr.MGRDatabaseDiscoveryType.findPrimaryDataSourceURL(MGRDatabaseDiscoveryType.java:143)
        at 
org.apache.shardingsphere.dbdiscovery.mgr.MGRDatabaseDiscoveryType.determinePrimaryDataSource(MGRDatabaseDiscoveryType.java:134)
        at 
org.apache.shardingsphere.dbdiscovery.mgr.MGRDatabaseDiscoveryType.updatePrimaryDataSource(MGRDatabaseDiscoveryType.java:123)
        at 
org.apache.shardingsphere.dbdiscovery.rule.DatabaseDiscoveryRule.findMasterSlaveRelation(DatabaseDiscoveryRule.java:128)
        at 
org.apache.shardingsphere.dbdiscovery.rule.DatabaseDiscoveryRule.<init>(DatabaseDiscoveryRule.java:85)
        at 
org.apache.shardingsphere.dbdiscovery.rule.DatabaseDiscoveryRule.<init>(DatabaseDiscoveryRule.java:73)
        at 
org.apache.shardingsphere.dbdiscovery.rule.builder.DatabaseDiscoveryRuleBuilder.build(DatabaseDiscoveryRuleBuilder.java:46)
        at 
org.apache.shardingsphere.dbdiscovery.rule.builder.DatabaseDiscoveryRuleBuilder.build(DatabaseDiscoveryRuleBuilder.java:36)
        at 
org.apache.shardingsphere.infra.rule.builder.schema.SchemaRulesBuilder.buildRules(SchemaRulesBuilder.java:85)
        at 
org.apache.shardingsphere.infra.rule.builder.schema.SchemaRulesBuilder.buildRules(SchemaRulesBuilder.java:70)
        at 
org.apache.shardingsphere.mode.manager.ContextManager.buildChangedMetaDataContext(ContextManager.java:405)
        at 
org.apache.shardingsphere.mode.manager.ContextManager.alterRuleConfiguration(ContextManager.java:194)
        at 
org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterContextManagerCoordinator.renew(ClusterContextManagerCoordinator.java:121)
        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$1(CuratorZookeeperRepository.java:247)
        at 
org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.sendEvent(TreeCacheListenerWrapper.java:71)
        at 
org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.event(TreeCacheListenerWrapper.java:48)
        at 
org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.lambda$event$0(CuratorCacheListenerBuilderImpl.java:149)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at 
org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.event(CuratorCacheListenerBuilderImpl.java:149)
        at 
org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$putStorage$6(CuratorCacheImpl.java:274)
        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$$$capture(CompletableFuture.java:1626)
        at 
java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java)
        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)
   ```
   
   ### Reason analyze (If you can)
   
   
![image](https://user-images.githubusercontent.com/33742097/146322537-3ce381a0-89b9-44a7-b9bf-d7860aa4011b.png)
   
   ### My configuration :
   
   `Proxy config:`
   
   
   ```
   schemaName: database_discovery_db
   
   dataSources:
     ds_0:
       url: 
jdbc:mysql://127.0.0.1:13306/demo_primary_ds?serverTimezone=UTC&useSSL=false
       username: root
       password: 123456
       connectionTimeoutMilliseconds: 3000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
     ds_1:
       url: 
jdbc:mysql://127.0.0.1:13307/demo_primary_ds?serverTimezone=UTC&useSSL=false
       username: root
       password: 123456
       connectionTimeoutMilliseconds: 3000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
     ds_2:
       url: 
jdbc:mysql://127.0.0.1:13308/demo_primary_ds?serverTimezone=UTC&useSSL=false
       username: root
       password: 123456
       connectionTimeoutMilliseconds: 3000
       idleTimeoutMilliseconds: 50000
       maxLifetimeMilliseconds: 1300000
       maxPoolSize: 50
       minPoolSize: 1
   
   rules:
   - !DB_DISCOVERY
     dataSources:
       pr_ds:
         dataSourceNames:
           - ds_0
           - ds_1
           - ds_2
         discoveryHeartbeatName: mgr-heartbeat
         discoveryTypeName: mgr
     discoveryHeartbeats:
       mgr-heartbeat:
         props:
           keepAliveCron: '0/5 * * * * ?'
     discoveryTypes:
       mgr:
         type: MGR
         props:
           groupName: b13df29e-90b6-11e8-8d1b-525400fc3996
   ```
   
   `JDBC config :`
   
   
   ```
   ## mybatis的配置
   mybatis:
     mapper-locations: classpath*:mapper/**/*Mapper.xml
     type-aliases-package: com.shardingsphere
   
   
   server:
     port: 8899
   spring:
     shardingsphere:
       props:
         sql-show: true
       datasource:
         ds-0:
           jdbc-url: 
jdbc:mysql://127.0.0.1:13306/demo_primary_ds?serverTimezone=UTC&useSSL=false
           username: root
           password: 123456
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
         ds-1:
           jdbc-url: 
jdbc:mysql://127.0.0.1:13307/demo_primary_ds?serverTimezone=UTC&useSSL=false
           username: root
           password: 123456
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
         ds-2:
           jdbc-url: 
jdbc:mysql://127.0.0.1:13308/demo_primary_ds?serverTimezone=UTC&useSSL=false
           username: root
           password: 123456
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
         names: ds-0, ds-1, ds-2
       rules:
         readwrite-splitting:
           data-sources:
             rd_rs:
               auto-aware-data-source-name: pr_ds
         database-discovery:
           data-sources:
             pr_ds:
               data-source-names: ds-0, ds-1, ds-2
               discovery-type-name: mgr
               discovery-heartbeat-name: mgr-heartbeat
   
           discovery-types:
             mgr:
               type: MGR
               props:
                 groupName: b13df29e-90b6-11e8-8d1b-525400fc3996
   
           discovery-heartbeats:
             mgr-heartbeat:
               props:
                 keepAliveCron: '0/5 * * * * ?'
       mode:
         type: Cluster
         repository:
           type: Zookeeper
           props:
             namespace: governance_ds
             server-lists: localhost:2181
             retryIntervalMilliseconds: 500
             timeToLiveSeconds: 60
             maxRetries: 3
             operationTimeoutMilliseconds: 500
         overwrite: false
   
   
   
   ```
   


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


Reply via email to