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 2020/04/16 09:57:57 UTC
[GitHub] [incubator-shardingsphere] taojintianxia opened a new issue #5212:
can not insert into proxy
taojintianxia opened a new issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212
## Question
before I create this issue , gooled the corresponding question, but I didn't get anything useful. I knew yonglun is the expert of proxy, so I assined this issue to your directly @tuohai666
I tried to migrate a mysql database `test` to shardingsphere by `sharding-scaling` , but I got following exception :
```
Caused by: java.sql.SQLException: 2Unknown exception: [No signature of method: java.lang.String.mod() is applicable for argument types: (java.lang.Integer) values: [2]
Possible solutions: drop(int), find(), any(), find(groovy.lang.Closure), find(java.lang.CharSequence), is(java.lang.Object)]
```
I tried to debug the code , it triggered during an insert clause, so I copy the insert sql and execute it in a mysql client as following :
```
mysql> INSERT INTO `t_order`(`id`,`user_id`) VALUES(3,`103`);
ERROR 10002 (C1000): 2Unknown exception: [org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment cannot be cast to org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.ExpressionSegment]
```
the insert clause is generated by sharding-scaling. and following is one of the sharding table structure created by proxy :
```
CREATE TABLE `t_order_0` (
`id` int(11) NOT NULL,
`user_id` varchar(12) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
```
followings are the my `config-sharding.yaml`
```
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
username: root
password: root
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_1:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
username: root
password: root
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
shardingRule:
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_id
bindingTables:
- t_order
defaultDatabaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_${user_id % 2}
defaultTableStrategy:
none:
```
I found something I don't quite understand , that's when I try to insert the data by following , it works. I just cut of the ``` symbol
```
INSERT INTO `t_order`(`id`,`user_id`) VALUES(3,103);
```
I don't think It's a bug, just I don't uses it correctly . please guide me or give me some tips to solve this .
thanks in advance.
BTW It likes the issue (4460)[https://github.com/apache/incubator-shardingsphere/issues/4460], but I can't change the insert clause because it generated by sharding-scaling .
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] kimmking edited a comment on issue
#5212: can not insert into proxy
Posted by GitBox <gi...@apache.org>.
kimmking edited a comment on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614553236
Scaling does not release now.
BTW: just like another issue, this error cause by a wrong data type during invoking sharding expression.You can join to improve it with more investigation about tunning the wrong type how to occur.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion edited a comment on issue
#5212: can not insert into proxy
Posted by GitBox <gi...@apache.org>.
KomachiSion edited a comment on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614976837
your `user_id` is varcher type which will be map to `String` java type. So your configuration need some change like :
```
defaultDatabaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_${Integer.parseInt(user_id) % 2}
```
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] kimmking commented on issue #5212: can
not insert into proxy
Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614553236
Scaling does not release now.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] kimmking edited a comment on issue
#5212: can not insert into proxy
Posted by GitBox <gi...@apache.org>.
kimmking edited a comment on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614553236
Scaling does not release now.
BTW: just like another issue, this error cause by a wrong data type invoking sharding expression.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] taojintianxia commented on issue #5212:
can not insert into proxy
Posted by GitBox <gi...@apache.org>.
taojintianxia commented on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614569677
I see
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] taojintianxia closed issue #5212: can
not insert into proxy
Posted by GitBox <gi...@apache.org>.
taojintianxia closed issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] kimmking edited a comment on issue
#5212: can not insert into proxy
Posted by GitBox <gi...@apache.org>.
kimmking edited a comment on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614553236
Scaling does not release now, just like another issue, this error cause by a wrong data type during invoking sharding expression.
BTW: You can join to improve it with more investigation about tunning the wrong type how to occur.
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #5212:
can not insert into proxy
Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614976837
your `user_id` is varcher type which will be map to `String` java type. So your configuration need some change like :
```
defaultDatabaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_${Integer.parse(user_id) % 2}
```
----------------------------------------------------------------
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
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] kimmking edited a comment on issue
#5212: can not insert into proxy
Posted by GitBox <gi...@apache.org>.
kimmking edited a comment on issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212#issuecomment-614553236
Scaling does not release now.
BTW: just like another issue, this error cause by a wrong data type during invoking sharding expression.
----------------------------------------------------------------
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
With regards,
Apache Git Services