Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Fix concurrency issue #114

Merged
merged 4 commits into from
Aug 28, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ This project includes:
vertx-web under The Apache Software License, Version 2.0 or Eclipse Public License - v 2.0
vertx-web-client under The Apache Software License, Version 2.0 or Eclipse Public License - v 1.0
vertx-web-common under The Apache Software License, Version 2.0 or Eclipse Public License - v 1.0
Visible Assertions under MIT

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Assuming you started a test environment using docker-compose, please refer to ex
"drivers/mariadb",
"D:\\drivers\\mariadb",
"/mnt/d/drivers/mariadb",
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar"
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar"
],
"driverClassName": "org.mariadb.jdbc.Driver",
...
Expand Down
8 changes: 4 additions & 4 deletions all-in-one.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /*.deb /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/clickhouse \
https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.5/clickhouse-jdbc-0.2.5-shaded.jar \
https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.3.1-patch/clickhouse-jdbc-0.3.1-patch-shaded.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/mariadb \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/mysql5 \
https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/mysql8 \
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.23/mysql-connector-java-8.0.23.jar \
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.26/mysql-connector-java-8.0.26.jar \
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/postgres \
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar \
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.23/postgresql-42.2.23.jar \
&& sed -i -e 's|\(^[[:space:]]*\)\(exec.*clickhouse-server.*$\)|\1exec -c clickhouse-jdbc-bridge >/dev/null \&\n\1\2|' /entrypoint.sh \
&& echo '{\n\
"$schema": "../datasource-schema.json",\n\
Expand Down
7 changes: 4 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ The latest tag points to the latest release from `master` branch. Branch tags li
```bash
docker run -d --name ch-jdbc-bridge -p9019:9019 \
-e MAVEN_REPO_URL="https://repo1.maven.org/maven2" \
-e JDBC_DRIVERS="org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar,org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar" yandex/clickhouse-jdbc-bridge
-e JDBC_DRIVERS="org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar,org/postgresql/postgresql/42.2.23/postgresql-42.2.23.jar" yandex/clickhouse-jdbc-bridge
```
If you prefer to use JDBC drivers and named datasources on host, you can use the following commands:
```bash
wget -P drivers \
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar \
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar
https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar \
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.23/postgresql-42.2.23.jar
wget -P datasources \
https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/mariadb10.json \
https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/postgres13.json
Expand Down Expand Up @@ -75,6 +75,7 @@ In order to customize the container, please refer to directory structure and sup
Environment Variable | Java System Property | Default Value | Remark
-- | -- | -- | --
CONFIG_DIR | jdbc-bridge.config.dir | config | Configuration directory
SERIAL_MODE | jdbc-bridge.serial.mode | false | Whether run query in serial mode or not
CUSTOM_DRIVER_LOADER | jdbc-bridge.driver.loader | true | Whether use custom driver class loader or not
DATASOURCE_CONFIG_DIR | jdbc-bridge.datasource.config.dir | datasources | Directory for named datasources
DEFAULT_VALUE | jdbc-bridge.type.default | false | Whether support default expression in column definition or not
Expand Down
2 changes: 1 addition & 1 deletion misc/perf-test/jdbc-bridge/config/datasources/mariadb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"mariadb": {
"driverUrls": [
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar"
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar"
],
"driverClassName": "org.mariadb.jdbc.Driver",
"jdbcUrl": "jdbc:mariadb://mariadb:3306/test?useSSL=false&useCompression=false&rewriteBatchedStatements=true",
Expand Down
1 change: 1 addition & 0 deletions misc/quick-start/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ services:
# Below are all default settings just for demonstration
environment:
CONFIG_DIR: config # configuration directory
SERIAL_MODE: "false" # whether run query in serial mode or not
HTTPD_CONFIG_FILE: httpd.json # httpd configuration file
SERVER_CONFIG_FILE: server.json # server configuration file
VERTX_CONFIG_FILE: vertx.json # vertx configuration file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ch-server": {
"aliases": ["self"],
"driverUrls": [
"https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.2.5/clickhouse-jdbc-0.2.5-shaded.jar"
"https://repo1.maven.org/maven2/ru/yandex/clickhouse/clickhouse-jdbc/0.3.1-patch/clickhouse-jdbc-0.3.1-patch-shaded.jar"
],
"driverClassName": "ru.yandex.clickhouse.ClickHouseDriver",
"jdbcUrl": "jdbc:clickhouse://ch-server:8123/system",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"elasticsearch": {
"driverUrls": [
"https://repo1.maven.org/maven2/com/amazon/opendistroforelasticsearch/client/opendistro-sql-jdbc/1.12.0.0/opendistro-sql-jdbc-1.12.0.0.jar"
"https://repo1.maven.org/maven2/com/amazon/opendistroforelasticsearch/client/opendistro-sql-jdbc/1.13.0.0/opendistro-sql-jdbc-1.13.0.0.jar"
],
"readOnly": true,
"connectionTestQuery": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"mariadb10": {
"driverUrls": [
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar"
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar"
],
"driverClassName": "org.mariadb.jdbc.Driver",
"jdbcUrl": "jdbc:mariadb://db-mariadb10/test?useSSL=false&useCompression=false&useOldAliasMetadataBehavior=true&allowMultiQueries=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "../../../../../docker/config/datasource.jschema",
"mysql8": {
"driverUrls": [
"https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.23/mysql-connector-java-8.0.23.jar"
"https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.26/mysql-connector-java-8.0.26.jar"
],
"driverClassName": "com.mysql.cj.jdbc.Driver",
"jdbcUrl": "jdbc:mysql://db-mysql8/test?allowPublicKeyRetrieval=true&useSSL=false&useCompression=false&useOldAliasMetadataBehavior=true&allowMultiQueries=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mappings": [{ "nativeType": "bool", "toType": "String" }]
},
"driverUrls": [
"https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar"
"https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.23/postgresql-42.2.23.jar"
],
"driverClassName": "org.postgresql.Driver",
"jdbcUrl": "jdbc:postgresql://db-postgres13/test",
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc-bridge</artifactId>
<packaging>jar</packaging>
<version>2.0.3-SNAPSHOT</version>
<version>2.0.4-SNAPSHOT</version>
<name>ClickHouse JDBC Bridge</name>
<url>https://github.com/ClickHouse/clickhouse-jdbc-bridge</url>
<description>JDBC bridge for ClickHouse.</description>
<inceptionYear>2019</inceptionYear>

<properties>
<caffeine.version>2.8.6</caffeine.version>
<dnsjava.version>3.3.1</dnsjava.version>
<vertx.version>3.9.5</vertx.version>
<caffeine.version>2.9.2</caffeine.version>
<dnsjava.version>3.4.1</dnsjava.version>
<vertx.version>3.9.8</vertx.version>
<micrometer.version>1.1.19</micrometer.version>
<slf4j.version>1.7.30</slf4j.version>
<slf4j.version>1.7.32</slf4j.version>
<hikaricp.version>3.4.5</hikaricp.version>
<project.current.year>2021</project.current.year>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<testcontainers.version>1.15.1</testcontainers.version>
<testcontainers.version>1.16.0</testcontainers.version>
<testng.version>6.14.3</testng.version>
<main.basedir>${project.basedir}</main.basedir>
<deploy-plugin.version>3.0.0-M1</deploy-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public class JdbcBridgeVerticle extends AbstractVerticle implements ExtensionMan
private static volatile long startTime;

private static final String CONFIG_PATH = Utils.getConfiguration("config", "CONFIG_DIR", "jdbc-bridge.config.dir");
private static final boolean SERIAL_MODE = Boolean
.valueOf(Utils.getConfiguration("false", "SERIAL_MODE", "jdbc-bridge.serial.mode"));

private static final int DEFAULT_SERVER_PORT = 9019;

Expand Down Expand Up @@ -264,10 +266,10 @@ private void startServer(JsonObject bridgeServerConfig, JsonObject httpServerCon
.handler(this::handleIdentifierQuote);
router.post("/columns_info").produces(RESPONSE_CONTENT_TYPE).handler(queryTimeoutHandler)
.handler(this::handleColumnsInfo);
router.post("/").produces(RESPONSE_CONTENT_TYPE).handler(queryTimeoutHandler)
.blockingHandler(this::handleQuery);
router.post("/").produces(RESPONSE_CONTENT_TYPE).handler(queryTimeoutHandler).blockingHandler(this::handleQuery,
SERIAL_MODE);
router.post("/write").produces(RESPONSE_CONTENT_TYPE).handler(queryTimeoutHandler)
.blockingHandler(this::handleWrite);
.blockingHandler(this::handleWrite, SERIAL_MODE);

log.info("Starting web server...");
int port = bridgeServerConfig.getInteger("serverPort", DEFAULT_SERVER_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,14 @@ protected final Connection getConnection() throws SQLException {

try {
conn.setAutoCommit(true);
} catch (Exception e) {
} catch (Throwable e) {
log.warn("Failed to enable auto-commit due to {}", e.getMessage());
}
}

try {
conn.setClientInfo(PROP_CLIENT_NAME, DEFAULT_CLIENT_NAME);
} catch (Exception e) {
} catch (Throwable e) {
log.warn("Failed call setClientInfo due to {}", e.getMessage());
}

Expand Down