Issue 1:
Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Searched open and closed GitHub issues.

Read documentation: ShardingSphere Doc.

Please pay attention on issues you submitted, because we maybe need more details.

If no response more than 7 days 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?

4.0.0-RC1

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

Sharding-JDBC

Expected behavior

insert success

Actual behavior

insert error

Reason analyze (If you can)

unknown

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

insert primary key null will report exception

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

https://github.com/M-make/jnote -> com.jdbc.sharding.TestSharding#testSharding

Issue 2:
Bug Report

Which version of ShardingSphere did you use?

5.1.1 Release

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

ShardingSphere-Proxy

Expected behavior

All the add-resources dist-sql will success if all the jdbc properties are correct.

Actual behavior

Add-resource dist-sql may failed after serveral success.

Reason analyze (If you can)

concurrent issue

datasource graceful close is triggered async in validate method

getting jdbc connection from datasource is required to fetch db meta in addresource method

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

executing add-resource distsql continuously may leads to this problem. In my case, client would receive exception after 2~3 successful add-resource distsql

and stacktrace in shardingproxy server :

[ERROR] 2022-05-24 20:01:09.465 [ShardingSphere-Command-5] o.a.s.p.b.t.d.r.r.AddResourceBackendHandler - Add resource failed
java.lang.IllegalArgumentException: HikariDataSource HikariDataSource (HikariPool-163) has been closed.
at org.apache.shardingsphere.infra.database.type.DatabaseTypeRecognizer.getDatabaseType(DatabaseTypeRecognizer.java:55)
at org.apache.shardingsphere.infra.database.type.DatabaseTypeRecognizer.getDatabaseType(DatabaseTypeRecognizer.java:44)
at org.apache.shardingsphere.infra.metadata.schema.loader.SchemaLoader.load(SchemaLoader.java:52)
at org.apache.shardingsphere.infra.metadata.database.loader.DatabaseLoader.load(DatabaseLoader.java:53)
at org.apache.shardingsphere.mode.metadata.MetaDataContextsBuilder.addSchema(MetaDataContextsBuilder.java:84)
at org.apache.shardingsphere.mode.manager.ContextManager.buildChangedMetaDataContextWithAddedDataSource(ContextManager.java:478)
at org.apache.shardingsphere.mode.manager.ContextManager.refreshMetaDataContext(ContextManager.java:451)
at org.apache.shardingsphere.mode.manager.ContextManager.addResource(ContextManager.java:232)
at org.apache.shardingsphere.proxy.backend.text.distsql.rdl.resource.AddResourceBackendHandler.execute(AddResourceBackendHandler.java:64)
at org.apache.shardingsphere.proxy.backend.text.distsql.rdl.resource.AddResourceBackendHandler.execute(AddResourceBackendHandler.java:45)
at org.apache.shardingsphere.proxy.backend.text.SchemaRequiredBackendHandler.execute(SchemaRequiredBackendHandler.java:51)
at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:97)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:100)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:72)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-163) has been closed.
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96)
at org.apache.shardingsphere.infra.database.type.DatabaseTypeRecognizer.getDatabaseType(DatabaseTypeRecognizer.java:52)
... 16 common frames omitted

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

not necessary