apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.87k stars 6.73k forks source link

When `Mode` uses the memory mode of `H2database`, `JDBCRepository` has a logical problem in processing Delete and Create SQL statements #33281

Open linghengqian opened 2 hours ago

linghengqian commented 2 hours ago

Feature Request

For English only, other languages will not be accepted.

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

Please answer these questions before submitting your issue. Thanks!

Is your feature request related to a problem?

Describe the feature you would like.

try (
                Connection connection = dataSource.getConnection();
                Statement statement = connection.createStatement()) {
            // TODO remove it later. Add for reset standalone test e2e's env. Need to close DataSource to release H2's memory data
            if (jdbcRepositoryProps.<String>getValue(JDBCRepositoryPropertyKey.JDBC_URL).contains("h2:mem:")) {
                try {
                    statement.execute("TRUNCATE TABLE `repository`");
                } catch (final SQLException ignored) {
                }
            }
            // Finish TODO
            statement.execute(repositorySQL.getCreateTableSQL());
        }

Error: 2024-10-16 18:25:17.896 [ForkJoinPool.commonPool-worker-1] o.a.s.m.r.s.jdbc.JDBCRepository - Delete JDBC data by key: /nodes/compute_nodes/online/proxy/d5904fbf-9528-417a-8c59-913700c8777f failed java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-7) has been closed. at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96) at org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository.delete(JDBCRepository.java:191) at org.apache.shardingsphere.mode.persist.service.ComputeNodePersistService.offline(ComputeNodePersistService.java:191) at org.apache.shardingsphere.mode.manager.ContextManager.close(ContextManager.java:212) at org.apache.shardingsphere.proxy.frontend.ShardingSphereProxy.close(ShardingSphereProxy.java:153) at org.apache.shardingsphere.proxy.frontend.ShardingSphereProxy.start(ShardingSphereProxy.java:80) at org.apache.shardingsphere.proxy.Bootstrap.main(Bootstrap.java:70) at org.apache.shardingsphere.test.natived.commons.proxy.ProxyTestingServer.lambda$new$0(ProxyTestingServer.java:48) at java.base@22.0.2/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) at java.base@22.0.2/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) at java.base@22.0.2/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507) at java.base@22.0.2/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1489) at java.base@22.0.2/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2071) at java.base@22.0.2/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2033) at java.base@22.0.2/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187) at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853) at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)


- I believe this can be improved.
linghengqian commented 2 hours ago