Skip to content

JDBC's Etcd cluster mode integration is broken #36672

@linghengqian

Description

@linghengqian

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

  • ShardingSphere-JDBC

Expected behavior

  • ShardingSphere JDBC's Etcd cluster mode integration works fine.

Actual behavior

  • ShardingSphere JDBC's Etcd cluster mode integration is broken.
  • This does not affect the execution of Etcd's unit tests alone, but the problem will be discovered once another cluster mode-related unit test is executed after executing Etcd's unit tests.

Reason analyze (If you can)

  • No sure.
  • Running org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest first and then org.apache.shardingsphere.test.natived.jdbc.modes.cluster.EtcdTest works fine. Additional tests I wrote locally demonstrate this.
  • However, if org.apache.shardingsphere.test.natived.jdbc.modes.cluster.EtcdTest is run first and then org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest, ZookeeperTest fails.
  • There is no such problem at all on JDK24. Unfortunately, additional verification showed that JDK 24 was also affected, but JUnit just happened to switch the order in which unit tests were executed. Also affected on JDK 21 and JDK 22.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

  • Take Windows 11 as an example. It is assumed that Git.Git is configured, and version-fox.vfox, PowerShell/PowerShell and Rancher Desktop are installed. Then delete the @DisabledOnOs(OS.WINDOWS) annotation of org.apache.shardingsphere.test.natived.jdbc.modes.cluster.EtcdTest. Then execute,
vfox add java
vfox install java@25-graalce
vfox use --global java@25-graalce
git clone [email protected]:apache/shardingsphere.git
cd ./shardingsphere/
./mvnw -PgenerateMetadata -e -T 1C clean verify
  • This will get the following log:
[INFO] Running org.apache.shardingsphere.test.natived.jdbc.modes.cluster.EtcdTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 35.88 s -- in org.apache.shardingsphere.test.natived.jdbc.modes.cluster.EtcdTest
[INFO] Running org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 141.3 s <<< FAILURE! -- in org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest
[ERROR] org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest.assertShardingInLocalTransactions -- Time elapsed: 141.2 s <<< ERROR!
org.awaitility.core.ConditionTimeoutException: Condition with Lambda expression in org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest was not fulfilled within 2 minutes.
        at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
        at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)
        at org.awaitility.core.CallableCondition.await(CallableCondition.java:26)
        at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1160)
        at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1129)
        at org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest.initEnvironment(ZookeeperTest.java:89)
        at org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest.assertShardingInLocalTransactions(ZookeeperTest.java:71)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
Caused by: org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException: Table or view 't_order' does not exist.
        at org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.lambda$checkTableExists$7(SimpleTableSegmentBinder.java:179)
        at org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
        at org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.checkTableExists(SimpleTableSegmentBinder.java:179)
        at org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder.bind(SimpleTableSegmentBinder.java:94)
        at org.apache.shardingsphere.infra.binder.engine.segment.dml.from.TableSegmentBinder.bind(TableSegmentBinder.java:57)
        at org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.lambda$bind$1(SelectStatementBinder.java:72)
        at java.base/java.util.Optional.map(Optional.java:260)
        at org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.bind(SelectStatementBinder.java:72)
        at org.apache.shardingsphere.infra.binder.engine.type.DMLStatementBindEngine.bind(DMLStatementBindEngine.java:45)
        at org.apache.shardingsphere.infra.binder.engine.SQLBindEngine.bindSQLStatement(SQLBindEngine.java:73)
        at org.apache.shardingsphere.infra.binder.engine.SQLBindEngine.bind(SQLBindEngine.java:59)
        at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.createQueryContext(ShardingSphereStatement.java:260)
        at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:247)
        at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:195)
        at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
        at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
        at org.apache.shardingsphere.test.natived.jdbc.modes.cluster.ZookeeperTest.lambda$initEnvironment$0(ZookeeperTest.java:91)
        at org.awaitility.core.CallableCondition$ConditionEvaluationWrapper.eval(CallableCondition.java:99)
        at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248)
        at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:328)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
        at java.base/java.lang.Thread.run(Thread.java:1474)

Example codes for reproduce this issue (such as a github link).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions