This is an automated email from the ASF dual-hosted git repository.
zstan pushed a commit to branch jdbc_over_thin_sql
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/jdbc_over_thin_sql by this
push:
new cf56989ad66 IGNITE-26617 Jdbc. Thin client jdbc connection does not
observe changes made by other connections of the same driver instance (#6771)
cf56989ad66 is described below
commit cf56989ad669f56a2c56e9a9fcd0d0a216d8cc6f
Author: Max Zhuravkov <[email protected]>
AuthorDate: Thu Oct 16 10:12:14 2025 +0300
IGNITE-26617 Jdbc. Thin client jdbc connection does not observe changes
made by other connections of the same driver instance (#6771)
---
.../ignite/jdbc/ItJdbcMultipleConnectionsTest.java | 2 -
.../org/apache/ignite/jdbc/IgniteJdbcDriver.java | 50 ++++++++++++++++------
2 files changed, 36 insertions(+), 16 deletions(-)
diff --git
a/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcMultipleConnectionsTest.java
b/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcMultipleConnectionsTest.java
index 2c6995bda8a..197246f37a7 100644
---
a/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcMultipleConnectionsTest.java
+++
b/modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcMultipleConnectionsTest.java
@@ -27,13 +27,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Multiple JDBC connections test.
*/
-@Disabled("https://issues.apache.org/jira/browse/IGNITE-26617")
public class ItJdbcMultipleConnectionsTest extends AbstractJdbcSelfTest {
private static final String URL1 = "jdbc:ignite:thin://127.0.0.1:10800";
private static final String URL2 = "jdbc:ignite:thin://127.0.0.1:10801";
diff --git
a/modules/jdbc/src/main/java/org/apache/ignite/jdbc/IgniteJdbcDriver.java
b/modules/jdbc/src/main/java/org/apache/ignite/jdbc/IgniteJdbcDriver.java
index 80f7cb0d8aa..1fc9d631444 100644
--- a/modules/jdbc/src/main/java/org/apache/ignite/jdbc/IgniteJdbcDriver.java
+++ b/modules/jdbc/src/main/java/org/apache/ignite/jdbc/IgniteJdbcDriver.java
@@ -19,6 +19,7 @@ package org.apache.ignite.jdbc;
import static
org.apache.ignite.internal.jdbc.ConnectionPropertiesImpl.URL_PREFIX;
import static
org.apache.ignite.internal.jdbc.proto.SqlStateCode.CLIENT_CONNECTION_FAILED;
+import static org.apache.ignite.internal.util.ViewUtils.sync;
import com.google.auto.service.AutoService;
import java.sql.Connection;
@@ -31,7 +32,6 @@ import java.util.Arrays;
import java.util.Properties;
import java.util.logging.Logger;
import org.apache.ignite.client.BasicAuthenticator;
-import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.client.IgniteClientAuthenticator;
import org.apache.ignite.client.IgniteClientConfiguration;
import org.apache.ignite.client.SslConfiguration;
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.client.HostAndPort;
import org.apache.ignite.internal.client.IgniteClientConfigurationImpl;
import org.apache.ignite.internal.client.TcpIgniteClient;
import org.apache.ignite.internal.client.proto.ProtocolVersion;
+import org.apache.ignite.internal.hlc.HybridTimestampTracker;
import org.apache.ignite.internal.jdbc.ConnectionProperties;
import org.apache.ignite.internal.jdbc.ConnectionPropertiesImpl;
import org.apache.ignite.internal.jdbc.JdbcClientQueryEventHandler;
@@ -175,6 +176,15 @@ public class IgniteJdbcDriver implements Driver {
/** Minor version. */
private static final int MINOR_VER = ProtocolVersion.LATEST_VER.minor();
+ /**
+ * Tracker of the latest time observed by client.
+ *
+ * <p>All connections created by this driver use the same tracker.
+ * This is done so that read-only transactions from different connections
can observe changes made in other connections,
+ * which in turn ensures visibility of changes when working through the
jdbc connection pool.
+ */
+ private final HybridTimestampTracker observableTimeTracker =
HybridTimestampTracker.atomicTracker(null);
+
/** {@inheritDoc} */
@Override
public Connection connect(String url, Properties props) throws
SQLException {
@@ -187,7 +197,7 @@ public class IgniteJdbcDriver implements Driver {
TcpIgniteClient client;
try {
- client = createIgniteClient(connProps);
+ client = createIgniteClient(connProps, observableTimeTracker);
} catch (Exception e) {
throw new SQLException("Failed to connect to server",
CLIENT_CONNECTION_FAILED, e);
}
@@ -240,7 +250,6 @@ public class IgniteJdbcDriver implements Driver {
/**
* Register the driver instance.
*
- * @return Driver instance.
* @throws RuntimeException when failed to register driver.
*/
private static synchronized void register() {
@@ -266,21 +275,34 @@ public class IgniteJdbcDriver implements Driver {
return instance != null;
}
- private static TcpIgniteClient createIgniteClient(ConnectionProperties
connProps) {
- String[] addresses = Arrays.stream(connProps.getAddresses())
+ private static TcpIgniteClient createIgniteClient(
+ ConnectionProperties connectionProperties,
+ HybridTimestampTracker observableTimeTracker
+ ) {
+ String[] addresses = Arrays.stream(connectionProperties.getAddresses())
.map(HostAndPort::toString)
.toArray(String[]::new);
- SslConfiguration sslConfiguration = extractSslConfiguration(connProps);
- IgniteClientAuthenticator authenticator =
extractAuthenticationConfiguration(connProps);
+ int networkTimeout = connectionProperties.getConnectionTimeout();
+
+ var cfg = new IgniteClientConfigurationImpl(
+ null,
+ addresses,
+ networkTimeout,
+
IgniteClientConfigurationImpl.DFLT_BACKGROUND_RECONNECT_INTERVAL,
+ null,
+ IgniteClientConfigurationImpl.DFLT_HEARTBEAT_INTERVAL,
+ IgniteClientConfigurationImpl.DFLT_HEARTBEAT_TIMEOUT,
+ null,
+ null,
+ extractSslConfiguration(connectionProperties),
+ false,
+ extractAuthenticationConfiguration(connectionProperties),
+ IgniteClientConfiguration.DFLT_OPERATION_TIMEOUT,
+
IgniteClientConfiguration.DFLT_SQL_PARTITION_AWARENESS_METADATA_CACHE_SIZE
+ );
- return (TcpIgniteClient) IgniteClient.builder()
- .addresses(addresses)
- .authenticator(authenticator)
- .ssl(sslConfiguration)
-
.operationTimeout(IgniteClientConfiguration.DFLT_OPERATION_TIMEOUT)
-
.backgroundReconnectInterval(IgniteClientConfigurationImpl.DFLT_BACKGROUND_RECONNECT_INTERVAL)
- .build();
+ return (TcpIgniteClient) sync(TcpIgniteClient.startAsync(cfg,
observableTimeTracker));
}
private static @Nullable SslConfiguration
extractSslConfiguration(ConnectionProperties connProps) {