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 2021/03/08 09:32:30 UTC
[GitHub] [shardingsphere] mingqing6364 opened a new issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
mingqing6364 opened a new issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607
### Which version of ShardingSphere did you use?
ShardingSphere-Proxy5.0
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy5.0 + mysql5.7.33 + zookeeper3.6
### Expected behavior
When sharding-Proxy is running,the zookeeper have this note:
/${your_zk_namespace}/states/datanodes/${your_schema_name}/${your_replica_datasource_name}
### Actual behavior
zookeeper just have this note:
/${your_zk_namespace}/states/datanodes
by the way,I create the note,and set all slave disabled,sharding-proxy report errors: java.lang.ArithmeticException: / by zero
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
I run zookeeper in docker
```
docker pull zookeeper:3.6
docker create --name zk -p 2181:2181 zookeeper:3.6
docker start zk
docker exec -it zk bin/zkCli.sh
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
```
ShardingProxy config like this:
```
schemaName: replica_query_db
dataSourceCommon:
username: root
password: yKDSZE*F9s*oCvfk8hG^v@0YjHwEcFyv
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
maintenanceIntervalMilliseconds: 30000
dataSources:
primary_ds:
url: jdbc:mysql://127.0.0.1:3306/test_db?serverTimezone=UTC&useSSL=false
replica_ds_0:
url: jdbc:mysql://127.0.0.1:3306/test_db?serverTimezone=UTC&useSSL=false
rules:
- !REPLICA_QUERY
dataSources:
pr_ds:
name: pr_ds
primaryDataSourceName: primary_ds
replicaDataSourceNames:
- replica_ds_0
```
the server config like this:
```
governance:
name: governance_ds
registryCenter:
type: ZooKeeper
serverLists: localhost:2181
props:
retryIntervalMilliseconds: 500
timeToLiveSeconds: 60
maxRetries: 3
operationTimeoutMilliseconds: 500
overwrite: false
authentication:
users:
root:
password: root
props:
sql-show: true
```
start the sharding-proxy,and query the zookeeper
```
[zk: localhost:2181(CONNECTED) 4] ls /governance_ds/states/datanodes
[]
[zk: localhost:2181(CONNECTED) 5] get /governance_ds/states/datanodes
```
run sql like this:
```
[root@localhost ~]# mysql -uroot -p -h127.0.0.1 -P3307 -A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.33-log-ShardingSphere-Proxy 5.0.0-RC1
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+------------------+
| Database |
+------------------+
| replica_query_db |
+------------------+
1 row in set (0.02 sec)
mysql> use replica_query_db;
Database changed
mysql> select 1 a;
+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.17 sec)
mysql>
```
the sharding-proxy logs like this:
```
[INFO ] 17:25:18.163 [ShardingSphere-Command-1] ShardingSphere-SQL - Logic SQL: select 1 a
[INFO ] 17:25:18.163 [ShardingSphere-Command-1] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
[INFO ] 17:25:18.163 [ShardingSphere-Command-1] ShardingSphere-SQL - Actual SQL: replica_ds_0 ::: select 1 a
```
then I create the note in zookeeper,and set slave disabled:
```
[zk: localhost:2181(CONNECTED) 8] create /governance_ds/states/datanodes/replica_query_db
Created /governance_ds/states/datanodes/replica_query_db
[zk: localhost:2181(CONNECTED) 9] create /governance_ds/states/datanodes/replica_query_db/replica_ds_0
Created /governance_ds/states/datanodes/replica_query_db/replica_ds_0
[zk: localhost:2181(CONNECTED) 10] set /governance_ds/states/datanodes/replica_query_db/replica_ds_0 disabled
[zk: localhost:2181(CONNECTED) 11] get /governance_ds/states/datanodes/replica_query_db/replica_ds_0
disabled
[zk: localhost:2181(CONNECTED) 12]
```
set the sql:
```
mysql> select 1 a;
ERROR 10002 (C1000): 2Unknown exception: [/ by zero]
```
the sharding logs:
```
[INFO ] 17:25:18.163 [ShardingSphere-Command-1] ShardingSphere-SQL - Logic SQL: select 1 a
[INFO ] 17:25:18.163 [ShardingSphere-Command-1] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
[INFO ] 17:25:18.163 [ShardingSphere-Command-1] ShardingSphere-SQL - Actual SQL: replica_ds_0 ::: select 1 a
[ERROR] 17:29:08.546 [ShardingSphere-Command-0] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.ArithmeticException: / by zero
at org.apache.shardingsphere.replicaquery.algorithm.RoundRobinReplicaLoadBalanceAlgorithm.getDataSource(RoundRobinReplicaLoadBalanceAlgorithm.java:45)
at org.apache.shardingsphere.replicaquery.route.engine.impl.ReplicaQueryDataSourceRouter.route(ReplicaQueryDataSourceRouter.java:46)
at org.apache.shardingsphere.replicaquery.route.engine.ReplicaQuerySQLRouter.createRouteContext(ReplicaQuerySQLRouter.java:46)
at org.apache.shardingsphere.replicaquery.route.engine.ReplicaQuerySQLRouter.createRouteContext(ReplicaQuerySQLRouter.java:41)
at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:59)
at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:57)
at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:52)
at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:77)
at org.apache.shardingsphere.proxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:61)
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)
```
### 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
[GitHub] [shardingsphere] mingqing6364 commented on issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
Posted by GitBox <gi...@apache.org>.
mingqing6364 commented on issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607#issuecomment-794936352
> Under replica query scenarios, you should ensure that at least one replica data node is available.
If all slave is disabled,can run sql in master.
----------------------------------------------------------------
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
[GitHub] [shardingsphere] terrymanu closed issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607#issuecomment-927302740
Only replica can be disabled
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] avalon5666 commented on issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607#issuecomment-793863614
Under replica query scenarios, you should ensure that at least one data node is available.
----------------------------------------------------------------
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
[GitHub] [shardingsphere] avalon5666 commented on issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607#issuecomment-795292467
Config another replica ds same as primary ds.
----------------------------------------------------------------
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
[GitHub] [shardingsphere] avalon5666 edited a comment on issue #9607: ShardingProxy5.0 can't register slave db at zookeeper3.6
Posted by GitBox <gi...@apache.org>.
avalon5666 edited a comment on issue #9607:
URL: https://github.com/apache/shardingsphere/issues/9607#issuecomment-793863614
Under replica query scenarios, you should ensure that at least one replica data node is available.
----------------------------------------------------------------
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