shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

4.0.0-RC2-sharding-proxy JDBCBackendDataSource.createConnection null

Open leehaut opened this issue 7 years ago • 1 comments

version: apache-shardingsphere-incubating-4.0.0-RC1-sharding-proxy

config-sharding.yaml

schemaName: demo_test

dataSources:
  ds0:
    url: jdbc:postgresql://127.0.0.1:5432/app?allowEncodingChanges=true&client_encoding=UTF8
    username: postgres
    password: postgres
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
  ds1:
    url: jdbc:postgresql://127.0.0.2:5432/app?allowEncodingChanges=true&client_encoding=UTF8
    username: postgres
    password: postgres
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
  ds2:
    url: jdbc:postgresql://127.0.0.3:5432/app?allowEncodingChanges=true&client_encoding=UTF8
    username: postgres
    password: postgres
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50

shardingRule:
  tables:
    t_order:
      actualDataNodes: ds$->{0..2}.t_order
      databaseStrategy:
        inline:
          shardingColumn: user_id
          algorithmExpression: ds$->{Math.abs(user_id.hashCode() % 3)}
      tableStrategy:
        none:
    t_order_extra:
      actualDataNodes: ds$->{0..2}.t_order_extra
      databaseStrategy:
        inline:
          shardingColumn: user_id
          algorithmExpression: ds$->{Math.abs(user_id.hashCode() % 3)}
      tableStrategy:
        none:
    t_order_flow:
      actualDataNodes: ds$->{0..2}.t_order_flow
      databaseStrategy:
        inline:
          shardingColumn: user_id
          algorithmExpression: ds$->{Math.abs(user_id.hashCode() % 3)}
      tableStrategy:
        none:
  bindingTables:
    - t_order,t_order_extra,t_order_flow

Error logs

[DEBUG] 16:14:33.503 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Read from client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 00 00 00 08 04 d2 16 2f                         |......./        |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.506 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 4e                                              |N               |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.508 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Read from client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 00 00 00 2e 00 03 00 00 75 73 65 72 00 72 6f 6f |........user.roo|
|00000010| 74 00 64 61 74 61 62 61 73 65 00 7a 63 5f 61 70 |t.database.zc_ap|
|00000020| 70 6d 61 6e 61 67 65 5f 74 65 73 74 00 00       |pmanage_test..  |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.512 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 52 00 00 00 08 00 00 00 00                      |R........       |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.513 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 53 00 00 00 17 73 65 72 76 65 72 5f 76 65 72 73 |S....server_vers|
|00000010| 69 6f 6e 00 38 2e 34 00                         |ion.8.4.        |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.513 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 53 00 00 00 19 63 6c 69 65 6e 74 5f 65 6e 63 6f |S....client_enco|
|00000010| 64 69 6e 67 00 55 54 46 38 00                   |ding.UTF8.      |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.513 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 53 00 00 00 19 73 65 72 76 65 72 5f 65 6e 63 6f |S....server_enco|
|00000010| 64 69 6e 67 00 55 54 46 38 00                   |ding.UTF8.      |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.514 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 5a 00 00 00 05 49                               |Z....I          |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.514 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Read from client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 51 00 00 00 25 73 65 74 20 63 6c 69 65 6e 74 5f |Q...%set client_|
|00000010| 65 6e 63 6f 64 69 6e 67 20 74 6f 20 27 55 4e 49 |encoding to 'UNI|
|00000020| 43 4f 44 45 27 00                               |CODE'.          |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:33.527 [pool-4-thread-1] o.a.s.s.f.p.c.PostgreSQLCommandExecutorFactory - Execute packet type: QUERY, value: PostgreSQLComQueryPacket(sql=set client_encoding to 'UNICODE')
[INFO ] 16:14:33.813 [pool-4-thread-1] ShardingSphere-SQL - Rule Type: sharding
[INFO ] 16:14:33.813 [pool-4-thread-1] ShardingSphere-SQL - Logic SQL: set client_encoding to 'UNICODE'
[INFO ] 16:14:33.814 [pool-4-thread-1] ShardingSphere-SQL - SQLStatement: TransparentOptimizedStatement(tables=Tables(tables=[], schema=Optional.absent()))
[INFO ] 16:14:33.814 [pool-4-thread-1] ShardingSphere-SQL - Actual SQL: ds0 ::: set client_encoding to 'UNICODE'
[INFO ] 16:14:33.814 [pool-4-thread-1] ShardingSphere-SQL - Actual SQL: ds1 ::: set client_encoding to 'UNICODE'
[INFO ] 16:14:33.814 [pool-4-thread-1] ShardingSphere-SQL - Actual SQL: ds2 ::: set client_encoding to 'UNICODE'
[DEBUG] 16:14:34.149 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 43 00 00 00 05 00                               |C.....          |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:34.149 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 43 00 00 00 05 00                               |C.....          |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:34.151 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 5a 00 00 00 05 49                               |Z....I          |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:34.158 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Read from client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 51 00 00 01 1d 53 45 4c 45 43 54 20 64 2e 64 61 |Q....SELECT d.da|
|00000010| 74 6e 61 6d 65 2c 20 64 2e 6f 69 64 2c 20 70 67 |tname, d.oid, pg|
|00000020| 5f 67 65 74 5f 75 73 65 72 62 79 69 64 28 64 2e |_get_userbyid(d.|
|00000030| 64 61 74 64 62 61 29 20 41 53 20 6f 77 6e 65 72 |datdba) AS owner|
|00000040| 2c 20 73 68 6f 62 6a 5f 64 65 73 63 72 69 70 74 |, shobj_descript|
|00000050| 69 6f 6e 28 64 2e 6f 69 64 2c 20 27 70 67 5f 64 |ion(d.oid, 'pg_d|
|00000060| 61 74 61 62 61 73 65 27 29 20 41 53 20 63 6f 6d |atabase') AS com|
|00000070| 6d 65 6e 74 2c 20 74 2e 73 70 63 6e 61 6d 65 2c |ment, t.spcname,|
|00000080| 20 64 2e 64 61 74 61 63 6c 2c 20 64 2e 64 61 74 | d.datacl, d.dat|
|00000090| 6c 61 73 74 73 79 73 6f 69 64 2c 20 64 2e 65 6e |lastsysoid, d.en|
|000000a0| 63 6f 64 69 6e 67 2c 20 70 67 5f 65 6e 63 6f 64 |coding, pg_encod|
|000000b0| 69 6e 67 5f 74 6f 5f 63 68 61 72 28 64 2e 65 6e |ing_to_char(d.en|
|000000c0| 63 6f 64 69 6e 67 29 20 41 53 20 65 6e 63 6f 64 |coding) AS encod|
|000000d0| 69 6e 67 6e 61 6d 65 20 46 52 4f 4d 20 70 67 5f |ingname FROM pg_|
|000000e0| 64 61 74 61 62 61 73 65 20 64 20 4c 45 46 54 20 |database d LEFT |
|000000f0| 4a 4f 49 4e 20 70 67 5f 74 61 62 6c 65 73 70 61 |JOIN pg_tablespa|
|00000100| 63 65 20 74 20 4f 4e 20 64 2e 64 61 74 74 61 62 |ce t ON d.dattab|
|00000110| 6c 65 73 70 61 63 65 3d 74 2e 6f 69 64 00       |lespace=t.oid.  |
+--------+-------------------------------------------------+----------------+
[DEBUG] 16:14:34.159 [pool-4-thread-1] o.a.s.s.f.p.c.PostgreSQLCommandExecutorFactory - Execute packet type: QUERY, value: PostgreSQLComQueryPacket(sql=SELECT d.datname, d.oid, pg_get_userbyid(d.datdba) AS owner, shobj_description(d.oid, 'pg_database') AS comment, t.spcname, d.datacl, d.datlastsysoid, d.encoding, pg_encoding_to_char(d.encoding) AS encodingname FROM pg_database d LEFT JOIN pg_tablespace t ON d.dattablespace=t.oid)
[INFO ] 16:14:34.306 [pool-4-thread-1] ShardingSphere-SQL - Rule Type: sharding
[INFO ] 16:14:34.306 [pool-4-thread-1] ShardingSphere-SQL - Logic SQL: SELECT d.datname, d.oid, pg_get_userbyid(d.datdba) AS owner, shobj_description(d.oid, 'pg_database') AS comment, t.spcname, d.datacl, d.datlastsysoid, d.encoding, pg_encoding_to_char(d.encoding) AS encodingname FROM pg_database d LEFT JOIN pg_tablespace t ON d.dattablespace=t.oid
[INFO ] 16:14:34.307 [pool-4-thread-1] ShardingSphere-SQL - SQLStatement: ShardingSelectOptimizedStatement(tables=Tables(tables=[Table(name=pg_database, alias=Optional.of(d)), Table(name=pg_tablespace, alias=Optional.of(t))], schema=Optional.absent()), groupBy=org.apache.shardingsphere.core.optimize.sharding.segment.select.groupby.GroupBy@7ce4d4d9, orderBy=org.apache.shardingsphere.core.optimize.sharding.segment.select.orderby.OrderBy@61706b36, selectItems=SelectItems(startIndex=7, stopIndex=209, distinctRow=false, items=[ColumnSelectItem(owner=d, name=datname, alias=Optional.absent()), ColumnSelectItem(owner=d, name=oid, alias=Optional.absent()), ExpressionSelectItem(expression=pg_get_userbyid(d.datdba), alias=Optional.of(owner)), ExpressionSelectItem(expression=shobj_description(d.oid,'pg_database'), alias=Optional.of(comment)), ColumnSelectItem(owner=t, name=spcname, alias=Optional.absent()), ColumnSelectItem(owner=d, name=datacl, alias=Optional.absent()), ColumnSelectItem(owner=d, name=datlastsysoid, alias=Optional.absent()), ColumnSelectItem(owner=d, name=encoding, alias=Optional.absent()), ExpressionSelectItem(expression=pg_encoding_to_char(d.encoding), alias=Optional.of(encodingname))], tables=[TableSegment(startIndex=216, stopIndex=226, name=pg_database, quoteCharacter=NONE, owner=Optional.absent(), alias=Optional.of(d)), TableSegment(startIndex=240, stopIndex=252, name=pg_tablespace, quoteCharacter=NONE, owner=Optional.absent(), alias=Optional.of(t))]), pagination=org.apache.shardingsphere.core.optimize.sharding.segment.select.pagination.Pagination@56c47834, containsSubquery=false)
[INFO ] 16:14:34.308 [pool-4-thread-1] ShardingSphere-SQL - Actual SQL: null ::: SELECT d.datname, d.oid, pg_get_userbyid(d.datdba) AS owner, shobj_description(d.oid, 'pg_database') AS comment, t.spcname, d.datacl, d.datlastsysoid, d.encoding, pg_encoding_to_char(d.encoding) AS encodingname FROM pg_database d LEFT JOIN pg_tablespace t ON d.dattablespace=t.oid
[ERROR] 16:14:34.310 [pool-4-thread-1] o.a.s.s.f.c.CommandExecutorTask - Exception occur:
java.lang.NullPointerException: null
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.createConnection(JDBCBackendDataSource.java:150)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.datasource.JDBCBackendDataSource.getConnections(JDBCBackendDataSource.java:123)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnectionFromUnderlying(BackendConnection.java:189)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnectionsWithoutTransaction(BackendConnection.java:172)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.connection.BackendConnection.getConnections(BackendConnection.java:141)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.callback.ProxyJDBCExecutePrepareCallback.getConnections(ProxyJDBCExecutePrepareCallback.java:56)
        at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getSQLExecuteGroups(SQLExecutePrepareTemplate.java:89)
        at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getSynchronizedExecuteUnitGroups(SQLExecutePrepareTemplate.java:67)
        at org.apache.shardingsphere.core.execute.sql.prepare.SQLExecutePrepareTemplate.getExecuteUnitGroups(SQLExecutePrepareTemplate.java:59)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.execute.JDBCExecuteEngine.execute(JDBCExecuteEngine.java:78)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:95)
        at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:81)
        at org.apache.shardingsphere.shardingproxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:54)
        at org.apache.shardingsphere.shardingproxy.frontend.postgresql.command.query.text.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:68)
        at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:86)
        at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:66)
        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)
[DEBUG] 16:14:34.311 [nioEventLoopGroup-3-1] o.a.s.s.transport.codec.PacketCodec - Write to client 0a68eab8 :
          +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 45 00 00 00 05 00                               |E.....          |
+--------+-------------------------------------------------+----------------+

leehaut avatar Oct 15 '19 09:10 leehaut

why closed the issue? I found the same question.

haetao avatar Oct 21 '19 13:10 haetao