-
Notifications
You must be signed in to change notification settings - Fork 562
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
When JDBC Driver enables transactions and auto-commit, multi-threaded deletion will fail #2023
Comments
Good day, @linghengqian ! |
|
@linghengqian |
Thanks for your explanation, should I close the current issue? I don't think I know how to fix the current issue, since it's a bug on jdbc v1. |
Hi, @linghengqian !
Thanks! |
create table IF NOT EXISTS t_order
(
order_id Int64 NOT NULL,
order_type Int32,
user_id Int32 NOT NULL,
address_id Int64 NOT NULL,
status VARCHAR(50)
) engine = MergeTree
primary key (order_id)
order by (order_id);
TRUNCATE TABLE t_order;
-- Here, about `30` insert SQL statements will be executed.
INSERT INTO t_order (order_id, user_id, order_type, address_id, status) VALUES (?, ?, ?, ?, ?);
SELECT * FROM t_order;
-- Here, about `30` delete SQL statements will be executed. And the exception described in the current issue occurs here. I had to resort to `Awaitility.await().pollDelay(Duration.ofSeconds(5L)).until(() -> true);`.
alter table t_order delete where order_id=?;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@SuppressWarnings("SqlNoDataSourceInspection")
public class ExampleUtils {
public void test(DataSource dataSource) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
try {
connection.setAutoCommit(false);
connection.createStatement().executeUpdate("INSERT INTO t_order (order_id, user_id, order_type, address_id, status) VALUES (2024, 2024, 0, 13800000001, 'INSERT_TEST')");
connection.createStatement().executeUpdate("INSERT INTO t_order_does_not_exist (test_id_does_not_exist) VALUES (2024)");
connection.commit();
} catch (final SQLException ignored) {
connection.rollback();
} finally {
connection.setAutoCommit(true);
}
}
try (Connection conn = dataSource.getConnection();
ResultSet resultSet = conn.createStatement().executeQuery("SELECT * FROM t_order_item WHERE user_id = 2024")) {
assertThat(resultSet.next(), is(false));
}
}
} |
Describe the bug
Steps to reproduce
SDKMAN!
andDocker CE
.Expected behaviour
[INFO] Running io.github.linghengqian.MySqlTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.49 s -- in io.github.linghengqian.MySqlTest
Code example
Error log
org.awaitility.Awaitility.await().pollDelay(Duration.ofSeconds(5L)).until(() -> true);
to wait for 5 seconds each time before executing thealter table
SQL.Click me to view the complete error log🐳🐬🐡🦑🦞🐊🫎🦒
Configuration
Environment
0.7.1-patch1
OpenJDK 23
Ubuntu 22.04.4
ClickHouse server
24.11.1.2557
CREATE TABLE
statements for tables involved:The text was updated successfully, but these errors were encountered: