Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes JDBCRepository improper handling of H2database in memory mode #33282

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

### Enhancement
1. Proxy: Add query parameters and check for mysql kill processId - [#33274](https://github.com/apache/shardingsphere/pull/33274)
1. Proxy Native: Change the Base Docker Image of ShardingSphere Proxy Native - [#33263](https://github.com/apache/shardingsphere/issues/33263)

### Bug Fix

1. Mode: Fixes `JDBCRepository` improper handling of H2database in memory mode - [#33281](https://github.com/apache/shardingsphere/issues/33281)

### Change Log
1. [MILESTONE](https://github.com/apache/shardingsphere/milestone/30)

Expand Down Expand Up @@ -59,7 +62,6 @@
1. Infra: Support compiling and using ShardingSphere under OpenJDK 23 - [#33025](https://github.com/apache/shardingsphere/pull/33025)
1. Hive: Support Hive integration module to connect to HiveServer2 4.0.1 - [#33212](https://github.com/apache/shardingsphere/pull/33212)
1. Infra: Support building Example module with OpenJDK 23 - [#33224](https://github.com/apache/shardingsphere/pull/33224)
1. Proxy Native: Change the Base Docker Image of ShardingSphere Proxy Native - [#33263](https://github.com/apache/shardingsphere/issues/33263)

### Bug Fix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void init(final Properties props) {
try (
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.execute(repositorySQL.getCreateTableSQL());
// 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 {
Expand All @@ -74,7 +75,6 @@ public void init(final Properties props) {
}
}
// Finish TODO
statement.execute(repositorySQL.getCreateTableSQL());
}
}

Expand Down Expand Up @@ -185,8 +185,18 @@ public void update(final String key, final String value) {
}
}

/**
* Delete the specified row.
* Once the database connection involved in this row of data has been closed by other threads and this row of data is located in the H2Database started in memory mode,
* the data is actually deleted.
*
* @param key key of data
*/
@Override
public void delete(final String key) {
if (dataSource.isClosed() && dataSource.getJdbcUrl().startsWith("jdbc:h2:mem:")) {
return;
}
try (
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(repositorySQL.getDeleteSQL())) {
Expand Down