linghengqian commented on issue #34418:
URL:
https://github.com/apache/shardingsphere/issues/34418#issuecomment-2613944063
- My understanding is that to trigger the judgment condition of
`org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode.CONNECTION_STRICTLY`,
the value of `maxConnectionsSizePerQuery` of
`org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine`
needs to be less than the total number of
`org.apache.shardingsphere.infra.executor.sql.context.SQLUnit`. And
`maxConnectionsSizePerQuery` is obtained from `max-connections-size-per-query`
in the configuration file, and the default value is `1`.
- Building such a unit test requires some interesting hacking of HikariCP.
And this can only be reproduced with the help of the connection leak bug of
seata client 2.2.0.
```yaml
dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
jdbcUrl:
jdbc:tc:postgresql:17.2-bookworm://test-native-transactions-base/demo_ds_0?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
maximumPoolSize: 1
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
jdbcUrl:
jdbc:tc:postgresql:17.2-bookworm://test-native-transactions-base/demo_ds_1?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
maximumPoolSize: 1
ds_2:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
jdbcUrl:
jdbc:tc:postgresql:17.2-bookworm://test-native-transactions-base/demo_ds_2?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
maximumPoolSize: 1
```
```shell
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
68.62 s <<< FAILURE! -- in
org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest
[ERROR]
org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest.assertShardingInSeataTransactions
-- Time elapsed: 68.60 s <<< ERROR!
java.sql.SQLException:
More details: java.sql.SQLTransientConnectionException: HikariPool-58 -
Connection is not available, request timed out after 30001ms.
at
org.apache.shardingsphere.infra.exception.core.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:81)
at
org.apache.shardingsphere.infra.exception.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:54)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.executeUpdate(ShardingSphereStatement.java:138)
at
com.zaxxer.hikari.pool.ProxyStatement.executeUpdate(ProxyStatement.java:119)
at
com.zaxxer.hikari.pool.HikariProxyStatement.executeUpdate(HikariProxyStatement.java)
at
org.apache.shardingsphere.test.natived.commons.repository.OrderRepository.createTableIfNotExistsInPostgres(OrderRepository.java:76)
at
org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest.initEnvironment(SeataTest.java:102)
at
org.apache.shardingsphere.test.natived.jdbc.transactions.base.SeataTest.assertShardingInSeataTransactions(SeataTest.java:96)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
Caused by: java.sql.SQLTransientConnectionException: HikariPool-58 -
Connection is not available, request timed out after 30001ms.
at
com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:696)
at
com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:197)
at
com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:162)
at
com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128)
at
org.apache.shardingsphere.infra.database.core.metadata.database.datatype.DataTypeRegistry.load(DataTypeRegistry.java:53)
at
org.apache.shardingsphere.infra.database.core.metadata.data.loader.MetaDataLoader.load(MetaDataLoader.java:65)
at
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.loadSchemas(GenericSchemaBuilder.java:90)
at
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.build(GenericSchemaBuilder.java:73)
at
org.apache.shardingsphere.mode.metadata.refresher.metadata.pushdown.type.table.CreateTablePushDownMetaDataRefresher.refresh(CreateTablePushDownMetaDataRefresher.java:57)
at
org.apache.shardingsphere.mode.metadata.refresher.metadata.pushdown.type.table.CreateTablePushDownMetaDataRefresher.refresh(CreateTablePushDownMetaDataRefresher.java:45)
at
org.apache.shardingsphere.mode.metadata.refresher.metadata.pushdown.PushDownMetaDataRefreshEngine.refresh(PushDownMetaDataRefreshEngine.java:79)
at
org.apache.shardingsphere.driver.executor.engine.pushdown.jdbc.DriverJDBCPushDownExecuteUpdateExecutor.doExecuteUpdate(DriverJDBCPushDownExecuteUpdateExecutor.java:117)
at
org.apache.shardingsphere.driver.executor.engine.pushdown.jdbc.DriverJDBCPushDownExecuteUpdateExecutor.lambda$executeUpdate$0(DriverJDBCPushDownExecuteUpdateExecutor.java:93)
at
org.apache.shardingsphere.driver.executor.engine.transaction.DriverTransactionalExecutor.execute(DriverTransactionalExecutor.java:56)
at
org.apache.shardingsphere.driver.executor.engine.pushdown.jdbc.DriverJDBCPushDownExecuteUpdateExecutor.executeUpdate(DriverJDBCPushDownExecuteUpdateExecutor.java:92)
at
org.apache.shardingsphere.driver.executor.engine.DriverExecuteUpdateExecutor.executeUpdate(DriverExecuteUpdateExecutor.java:80)
at
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade.executeUpdate(DriverExecutorFacade.java:126)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.executeUpdate(ShardingSphereStatement.java:189)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.executeUpdate(ShardingSphereStatement.java:133)
... 8 more
```
--
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]