zhangwei1989 opened a new issue #8525:
URL: https://github.com/apache/shardingsphere/issues/8525


   ## Question
   
   Following is my situation:
   1. MacOS 10.14.6
   2. Mysql 5.7 running in Docker with three seperate container
   3. apache-shardingsphere-5.0.0-alpha-shardingsphere-proxy-bin
   
   Sharding-proxy was started without any problem, for i got the log:
   `[INFO ] 22:09:26.946 [main] o.a.s.p.frontend.ShardingSphereProxy - 
ShardingSphere-Proxy start success.`
   
   But when I run `show tables;` in mysql-cli, I got the following error logs:
   
   ```
   [ERROR] 22:10:25.712 [ShardingSphere-Command-5] 
o.a.s.p.f.c.CommandExecutorTask - Exception occur:
   java.lang.NullPointerException: Can not get connection from datasource pr_ds.
        at 
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:987)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.getConnections(JDBCBackendDataSource.java:80)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.getConnections(JDBCBackendDataSource.java:62)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection.getConnectionsWithoutTransaction(BackendConnection.java:141)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection.getConnections(BackendConnection.java:102)
        at 
org.apache.shardingsphere.infra.executor.sql.resourced.group.ResourceManagedExecuteGroupEngine.generateSQLExecuteGroups(ResourceManagedExecuteGroupEngine.java:66)
        at 
org.apache.shardingsphere.infra.executor.sql.group.AbstractExecuteGroupEngine.generate(AbstractExecuteGroupEngine.java:58)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.engine.jdbc.JDBCExecuteEngine.generateInputGroups(JDBCExecuteEngine.java:140)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.engine.jdbc.JDBCExecuteEngine.executeWithManagedResource(JDBCExecuteEngine.java:130)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.engine.jdbc.JDBCExecuteEngine.execute(JDBCExecuteEngine.java:123)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.engine.jdbc.JDBCExecuteEngine.execute(JDBCExecuteEngine.java:103)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.doExecute(JDBCDatabaseCommunicationEngine.java:93)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:79)
        at 
org.apache.shardingsphere.proxy.backend.text.admin.ShowTablesBackendHandler.execute(ShowTablesBackendHandler.java:65)
        at 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:62)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:100)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:76)
        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)
   ```
   
   My server.yaml is shown below:
   
   ```
   authentication:
    users:
      root:
        password: root
      sharding:
        password: sharding 
        authorizedSchemas: sharding_db
   
   props:
    max-connections-size-per-query: 1
    acceptor-size: 16  # The default value is available processors count * 2.
    executor-size: 16  # Infinite by default.
    proxy-frontend-flush-threshold: 128  # The default value is 128.
      # LOCAL: Proxy will run with LOCAL transaction.
      # XA: Proxy will run with XA transaction.
      # BASE: Proxy will run with B.A.S.E transaction.
    proxy-transaction-type: LOCAL
    proxy-opentracing-enabled: false
    proxy-hint-enabled: false
    query-with-cipher-column: true
    sql-show: false
    check-table-metadata-enabled: false
   ```
   
   And the url in the config-replica-query.yaml can be connected successfully 
with local mysql-cli. My config-replica-query.yaml is shown below:
   
   ```
   schemaName: replica_query_db
   
   dataSourceCommon:
    username: root
    password: admin123
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
    maintenanceIntervalMilliseconds: 30000
   
   dataSources:
    primary_ds:
      url: jdbc:mysql://192.168.99.100:3316/db?serverTimezone=UTC&useSSL=false
    replica_ds_0:
      url: jdbc:mysql://192.168.99.100:3326/db?serverTimezone=UTC&useSSL=false
    replica_ds_1:
      url: jdbc:mysql://192.168.99.100:3336/db?serverTimezone=UTC&useSSL=false
   
   rules:
   - !REPLICA_QUERY
    dataSources:
      pr_ds:
        name: pr_ds
        primaryDataSourceName: primary_ds
        replicaDataSourceNames:
          - replica_ds_0
          - replica_ds_1
   ```
   At last, mysql-connector-java-5.1.47.jar was in the folder with the name of 
ext-lib.
   
   I read documentation, searched open and closed issues, but I still can't 
figure out how to fix this. Can give me some tips?
   
   Thanks a lot!
   


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


Reply via email to