azexcy opened a new issue, #20009:
URL: https://github.com/apache/shardingsphere/issues/20009
## Bug Report
Relation: #17460
Table name is case-insensitive when altering sharding table
```
[INFO ] 2022-08-09 12:19:34.988 [Thread-9]
o.a.s.d.p.c.c.d.AbstractDataSourceChecker - checkEmpty, sql=SELECT * FROM
`t_order` LIMIT 1
[ERROR] 2022-08-09 12:19:35.075 [Thread-10]
o.a.c.f.r.l.InterProcessSemaphoreV2 - Sequential path not found:
/lock/exclusive/locks/prepare-0130317c30317c3054317c7368617264696e675f6462/leases/_c_d4699f34-f5fa-4497-9930-df0a502b1a96-lease-0000000001
[ERROR] 2022-08-09 12:19:35.080 [Thread-9] o.a.s.d.p.s.r.RuleAlteredJob -
job prepare failed, 0130317c30317c3054317c7368617264696e675f6462-0
java.lang.IllegalStateException: All tables must be in the same datasource.
at
com.google.common.base.Preconditions.checkState(Preconditions.java:508)
at
org.apache.shardingsphere.singletable.route.SingleTableSQLRouter.validateSameDataSource(SingleTableSQLRouter.java:118)
at
org.apache.shardingsphere.singletable.route.SingleTableSQLRouter.decorateRouteContext(SingleTableSQLRouter.java:80)
at
org.apache.shardingsphere.singletable.route.SingleTableSQLRouter.decorateRouteContext(SingleTableSQLRouter.java:52)
at
org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:59)
at
org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:53)
at
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:57)
at
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:49)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:489)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeQuery(ShardingSpherePreparedStatement.java:223)
at
org.apache.shardingsphere.data.pipeline.core.check.datasource.AbstractDataSourceChecker.checkEmpty(AbstractDataSourceChecker.java:69)
at
org.apache.shardingsphere.data.pipeline.core.check.datasource.AbstractDataSourceChecker.checkTargetTable(AbstractDataSourceChecker.java:55)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.checkTargetDataSource(RuleAlteredJobPreparer.java:183)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepareAndCheckTarget(RuleAlteredJobPreparer.java:137)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepareAndCheckTargetWithLock(RuleAlteredJobPreparer.java:113)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepare(RuleAlteredJobPreparer.java:86)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJob.prepare(RuleAlteredJob.java:101)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJob.lambda$execute$0(RuleAlteredJob.java:71)
at java.lang.Thread.run(Thread.java:750)
[WARN ] 2022-08-09 12:19:35.084 [Thread-10]
o.a.c.f.r.l.InterProcessSemaphoreV2 - Lease already released
org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode =
NoNode for
/mysql/lock/exclusive/locks/prepare-0130317c30317c3054317c7368617264696e675f6462/leases/_c_d4699f34-f5fa-4497-9930-df0a502b1a96-lease-0000000001
at org.apache.zookeeper.KeeperException.create(KeeperException.java:118)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
at org.apache.zookeeper.ZooKeeper.delete(ZooKeeper.java:2000)
at
org.apache.curator.framework.imps.DeleteBuilderImpl$5.call(DeleteBuilderImpl.java:274)
at
org.apache.curator.framework.imps.DeleteBuilderImpl$5.call(DeleteBuilderImpl.java:268)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:93)
at
org.apache.curator.framework.imps.DeleteBuilderImpl.pathInForeground(DeleteBuilderImpl.java:265)
at
org.apache.curator.framework.imps.DeleteBuilderImpl.forPath(DeleteBuilderImpl.java:249)
at
org.apache.curator.framework.imps.DeleteBuilderImpl.forPath(DeleteBuilderImpl.java:34)
at
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreV2$3.close(InterProcessSemaphoreV2.java:456)
at
org.apache.curator.shaded.com.google.common.io.Closeables.close(Closeables.java:78)
at
org.apache.curator.utils.CloseableUtils.closeQuietly(CloseableUtils.java:59)
at
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreV2.returnLease(InterProcessSemaphoreV2.java:198)
at
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreV2.internalAcquire1Lease(InterProcessSemaphoreV2.java:428)
at
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreV2.acquire(InterProcessSemaphoreV2.java:284)
at
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreV2.acquire(InterProcessSemaphoreV2.java:246)
at
org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex.acquire(InterProcessSemaphoreMutex.java:55)
at
org.apache.shardingsphere.mode.repository.cluster.zookeeper.lock.ZookeeperInternalLockHolder$ZookeeperInternalLock.tryLock(ZookeeperInternalLockHolder.java:101)
at
org.apache.shardingsphere.mode.repository.cluster.zookeeper.CuratorZookeeperRepository.tryLock(CuratorZookeeperRepository.java:272)
at
org.apache.shardingsphere.mode.manager.cluster.coordinator.ClusterLockPersistService.tryLock(ClusterLockPersistService.java:36)
at
org.apache.shardingsphere.mode.lock.manager.ShardingSphereLockManager.tryLock(ShardingSphereLockManager.java:43)
at
org.apache.shardingsphere.mode.lock.ShardingSphereLockContext.tryLock(ShardingSphereLockContext.java:43)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepareAndCheckTargetWithLock(RuleAlteredJobPreparer.java:111)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepare(RuleAlteredJobPreparer.java:86)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJob.prepare(RuleAlteredJob.java:101)
at
org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJob.lambda$execute$0(RuleAlteredJob.java:71)
at java.lang.Thread.run(Thread.java:750)
```
### Which version of ShardingSphere did you use?
master
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
### Expected behavior
Table name is case-insensitive when altering sharding table rule by DistSQL.
### Actual behavior
Table name is case-sensitive.
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
Same operation
```
mysql> use sharding_db;
Database changed
mysql> ADD RESOURCE ds_0 (
->
URL="jdbc:mysql://127.0.0.1:3306/ds_0?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true",
-> USER="root",
-> PASSWORD="Root@123"
-> ), ds_1 (
->
URL="jdbc:mysql://127.0.0.1:3306/ds_1?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true",
-> USER="root",
-> PASSWORD="Root@123"
-> );
Query OK, 0 rows affected (2.40 sec)
mysql> CREATE SHARDING TABLE RULE t_order(
-> RESOURCES(ds_0,ds_1),
-> SHARDING_COLUMN=order_id,
-> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=4)),
-> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
-> ), t_order_item(
-> RESOURCES(ds_0,ds_1),
-> SHARDING_COLUMN=order_id,
-> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=4)),
-> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
-> );
Query OK, 0 rows affected (2.15 sec)
mysql> CREATE SHARDING SCALING RULE scaling_manual
(INPUT(SHARDING_SIZE=1000), DATA_CONSISTENCY_CHECKER(TYPE(NAME=DATA_MATCH)));
Query OK, 0 rows affected (0.16 sec)
mysql> ADD RESOURCE ds_2 (
->
URL="jdbc:mysql://127.0.0.1:3306/ds_2?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true",
-> USER="root",
-> PASSWORD="Root@123"
-> ),ds_3 (
->
URL="jdbc:mysql://127.0.0.1:3306/ds_3?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true",
-> USER="root",
-> PASSWORD="Root@123"
-> ),ds_4 (
->
URL="jdbc:mysql://127.0.0.1:3306/ds_4?useServerPrepStmts=true&serverTimezone=UTC&useSSL=false&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true",
-> USER="root",
-> PASSWORD="Root@123"
-> );
Query OK, 0 rows affected (0.38 sec)
mysql> CREATE TABLE t_order (order_id INT NOT NULL, user_id INT NOT NULL,
status VARCHAR(45) NULL, PRIMARY KEY (order_id));
Query OK, 0 rows affected (0.56 sec)
mysql> ALTER SHARDING TABLE RULE T_ORDER(
-> RESOURCES(ds_2,ds_3,ds_4),
-> SHARDING_COLUMN=order_id,
-> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
-> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
-> );
Query OK, 0 rows affected (0.42 sec)
```
### 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.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]