|
3 | 3 | import com.clickhouse.client.api.Client; |
4 | 4 | import com.clickhouse.client.api.ClientConfigProperties; |
5 | 5 | import com.clickhouse.client.api.query.GenericRecord; |
| 6 | +import com.clickhouse.client.api.query.QuerySettings; |
| 7 | +import org.slf4j.Logger; |
| 8 | +import org.slf4j.LoggerFactory; |
6 | 9 | import org.testng.Assert; |
7 | 10 | import org.testng.annotations.Test; |
8 | 11 |
|
|
18 | 21 | import java.util.Arrays; |
19 | 22 | import java.util.List; |
20 | 23 | import java.util.Properties; |
| 24 | +import java.util.UUID; |
21 | 25 | import java.util.concurrent.TimeUnit; |
22 | 26 |
|
23 | 27 | import static org.testng.Assert.*; |
|
29 | 33 |
|
30 | 34 |
|
31 | 35 | public class StatementTest extends JdbcIntegrationTest { |
| 36 | + private static final Logger log = LoggerFactory.getLogger(StatementTest.class); |
| 37 | + |
32 | 38 | @Test(groups = { "integration" }) |
33 | 39 | public void testExecuteQuerySimpleNumbers() throws Exception { |
34 | 40 | try (Connection conn = getJdbcConnection()) { |
@@ -471,4 +477,28 @@ public void testConnectionExhaustion() throws Exception { |
471 | 477 | } |
472 | 478 | } |
473 | 479 | } |
| 480 | + |
| 481 | + @Test(groups = { "integration" }) |
| 482 | + public void testConcurrentCancel() throws Exception { |
| 483 | + try (Connection conn = getJdbcConnection()) { |
| 484 | + try (StatementImpl stmt = (StatementImpl) conn.createStatement()) { |
| 485 | + stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000"); |
| 486 | + stmt.cancel(); |
| 487 | + } |
| 488 | + try (StatementImpl stmt = (StatementImpl) conn.createStatement()) { |
| 489 | + new Thread(() -> { |
| 490 | + try { |
| 491 | + ResultSet rs = stmt.executeQuery("SELECT number FROM system.numbers LIMIT 10000000000"); |
| 492 | + rs.next(); |
| 493 | + log.info(rs.getObject(1).toString()); |
| 494 | + } catch (SQLException e) { |
| 495 | + log.error("Error in thread", e); |
| 496 | + } |
| 497 | + }).start(); |
| 498 | + |
| 499 | + Thread.sleep(1000); |
| 500 | + stmt.cancel(); |
| 501 | + } |
| 502 | + } |
| 503 | + } |
474 | 504 | } |
0 commit comments