Skip to content

Commit 677aadb

Browse files
authored
Merge pull request #86 from zhicwu/develop
Fix mutation error due to closed response
2 parents 1c221ec + d6d502e commit 677aadb

24 files changed

+234
-181
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ RUN apt-get update \
3838
apt-transport-https curl htop iftop iptraf iputils-ping jq lsof net-tools tzdata wget \
3939
&& apt-get clean \
4040
&& wget -q -P $JDBC_BRIDGE_HOME $JDBC_BRIDGE_REL_URL/LICENSE $JDBC_BRIDGE_REL_URL/NOTICE \
41-
$JDBC_BRIDGE_REL_URL/clickhouse-jdbc-bridge-${revision}.jar \
41+
$JDBC_BRIDGE_REL_URL/clickhouse-jdbc-bridge-${revision}-shaded.jar \
4242
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
4343

4444
COPY --chown=root:root docker/ $JDBC_BRIDGE_HOME
4545

4646
RUN chmod +x $JDBC_BRIDGE_HOME/*.sh \
4747
&& mkdir -p $JDBC_BRIDGE_HOME/logs /usr/local/lib/java \
4848
&& ln -s $JDBC_BRIDGE_HOME/logs /var/log/clickhouse-jdbc-bridge \
49-
&& ln -s $JDBC_BRIDGE_HOME/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION.jar \
50-
/usr/local/lib/java/clickhouse-jdbc-bridge.jar \
49+
&& ln -s $JDBC_BRIDGE_HOME/clickhouse-jdbc-bridge-${revision}-shaded.jar \
50+
/usr/local/lib/java/clickhouse-jdbc-bridge-shaded.jar \
5151
&& ln -s $JDBC_BRIDGE_HOME /etc/clickhouse-jdbc-bridge
5252

5353
WORKDIR $JDBC_BRIDGE_HOME

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,38 @@ JDBC bridge for ClickHouse®. It acts as a stateless proxy passing queries from
8989
--query="select * from jdbc('self?datasource_column', 'select 1')"
9090
```
9191

92+
* Debian/RPM Package
93+
94+
Besides docker, you can download and install released Debian/RPM package on existing Linux system.
95+
96+
Debian/Ubuntu
97+
```bash
98+
apt update && apt install -y procps wget
99+
export JDBC_BRIDGE_VERSION=2.0.0
100+
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge_$JDBC_BRIDGE_VERSION-1_all.deb
101+
apt install --no-install-recommends -f ./clickhouse-jdbc-bridge_$JDBC_BRIDGE_VERSION-1_all.deb
102+
clickhouse-jdbc-bridge
103+
```
104+
105+
CentOS/RHEL
106+
```bash
107+
yum install -y wget
108+
export JDBC_BRIDGE_VERSION=2.0.0
109+
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-1.noarch.rpm
110+
yum localinstall -y clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-1.noarch.rpm
111+
clickhouse-jdbc-bridge
112+
```
113+
92114
* Java CLI
93115

94116
```bash
95117
export JDBC_BRIDGE_VERSION=2.0.0
96-
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION.jar
118+
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v$JDBC_BRIDGE_VERSION/clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar
97119
# add named datasource
98120
wget -P config/datasources https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/ch-server.json
99121
# start jdbc bridge, and then issue below query in ClickHouse for testing
100122
# select * from jdbc('ch-server', 'select 1')
101-
java -jar clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION.jar
123+
java -jar clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar
102124
```
103125

104126

@@ -195,6 +217,13 @@ Assuming you started a test environment using docker-compose, please refer to ex
195217
196218
* Mutation
197219
```sql
220+
-- use query parameter
221+
select * from jdbc('ch-server?mutation', 'drop table if exists system.test_table');
222+
select * from jdbc('ch-server?mutation', 'create table system.test_table(a String, b UInt8) engine=Memory()');
223+
select * from jdbc('ch-server?mutation', 'insert into system.test_table values(''a'', 1)');
224+
select * from jdbc('ch-server?mutation', 'truncate table system.test_table');
225+
226+
-- use JDBC table engine
198227
drop table if exists system.test_table;
199228
create table system.test_table (
200229
a String,
@@ -205,7 +234,7 @@ Assuming you started a test environment using docker-compose, please refer to ex
205234
create table system.jdbc_table (
206235
a String,
207236
b UInt8
208-
) engine=JDBC('ch-server', 'system', 'test_table');
237+
) engine=JDBC('ch-server?batch_size=1000', 'system', 'test_table');
209238
210239
insert into system.jdbc_table(a, b) values('a', 1);
211240
@@ -280,8 +309,9 @@ Assuming you started a test environment using docker-compose, please refer to ex
280309
Couple of timeout settings you should be aware of:
281310
1. datasource timeout, for example: `max_execution_time` in MariaDB
282311
2. JDBC driver timeout, for example: `connectTimeout` and `socketTimeout` in [MariaDB Connector/J](https://mariadb.com/kb/en/about-mariadb-connector-j/)
283-
3. Vertx timeout - see `config/server.json` and `config/vertx.json`
284-
4. Client(ClickHouse JDBC driver) timeout - see timeout settings in ClickHouse JDBC driver
312+
3. JDBC bridge timeout, for examples: `queryTimeout` in `config/server.json`, and `maxWorkerExecuteTime` in `config/vertx.json`
313+
4. ClickHouse timeout like `max_execution_time` and `keep_alive_timeout` etc.
314+
5. Client timeout, for example: `socketTimeout` in ClickHouse JDBC driver
285315
286316
287317
## Migration
@@ -375,7 +405,7 @@ Test Case | Time Spent(s) | Throughput(#/s) | Failed Requests | Min(ms) | Mean(m
375405
[clickhouse_constant-query](misc/perf-test/results/clickhouse_constant-query.txt) | 797.775 | 125.35 | 0 | 1 | 159 | 4 | 1,077
376406
[clickhouse_constant-query(mysql)](misc/perf-test/results/clickhouse_constant-query(mysql).txt) | 1,598.426 | 62.56 | 0 | 7 | 320 | 18 | 2,049
377407
[clickhouse_constant-query(remote)](misc/perf-test/results/clickhouse_constant-query(remote).txt) | 802.212 | 124.66 | 0 | 2 | 160 | 8 | 3,073
378-
[clickhouse_constant-query(url)](misc/perf-test/results/clickhouclickhouse_constant-query(url)se_ping.txt) | 801.686 | 124.74 | 0 | 3 | 160 | 11 | 1,123
408+
[clickhouse_constant-query(url)](misc/perf-test/results/clickhouse_constant-query(url).txt) | 801.686 | 124.74 | 0 | 3 | 160 | 11 | 1,123
379409
[clickhouse_constant-query(jdbc)](misc/perf-test/results/clickhouse_constant-query(jdbc).txt) | 925.087 | 108.10 | 5,813 | 14 | 185 | 75 | 4,091
380410
[clickhouse(patched)_constant-query(jdbc)](misc/perf-test/results/clickhouse(patched)_constant-query(jdbc).txt) | 833.892 | 119.92 | 1,577 | 10 | 167 | 51 | 3,109
381411
[clickhouse(patched)_constant-query(jdbc-dual)](misc/perf-test/results/clickhouse(patched)_constant-query(jdbc-dual).txt) | 846.403 | 118.15 | 3,021 | 8 | 169 | 50 | 3,054

all-in-one.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ RUN apt-get update \
6969
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar \
7070
&& wget -q -P /etc/clickhouse-jdbc-bridge/drivers/postgres \
7171
https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.18/postgresql-42.2.18.jar \
72-
&& sed -i -e 's|\(^[[:space:]]*\)\(exec.*clickhouse-server.*$\)|\1exec clickhouse-jdbc-bridge\&\n\1\2|' /entrypoint.sh \
72+
&& sed -i -e 's|\(^[[:space:]]*\)\(exec.*clickhouse-server.*$\)|\1exec -c clickhouse-jdbc-bridge >/dev/null \&\n\1\2|' /entrypoint.sh \
7373
&& echo '{\n\
7474
"$schema": "../datasource-schema.json",\n\
7575
"self": {\n\

docker/config/server.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"requestTimeout": 5000,
3-
"queryTimeout": 30000,
3+
"queryTimeout": 60000,
44
"configScanPeriod": 5000,
55
"repositories": [
66
{

docker/docker-entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ start_server() {
2121
fi
2222

2323
if [ "$(echo ${CUSTOM_DRIVER_LOADER:="true"} | tr '[:upper:]' '[:lower:]')" != "true" ]; then
24-
local classpath="./clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION.jar:$(echo $(ls ${DRIVER_DIR:="drivers"}/*.jar) | tr ' ' ':'):."
24+
local classpath="./clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar:$(echo $(ls ${DRIVER_DIR:="drivers"}/*.jar) | tr ' ' ':'):."
2525
java -XX:+UseContainerSupport -XX:+IdleTuningCompactOnIdle -XX:+IdleTuningGcOnIdle \
2626
-Xdump:none -Xdump:tool:events=systhrow+throw,filter=*OutOfMemoryError,exec="kill -9 %pid" \
2727
-Dlog4j.configuration=file:///$JDBC_BRIDGE_HOME/log4j.properties -Dnashorn.args=--language=es6 \
@@ -30,7 +30,7 @@ start_server() {
3030
java -XX:+UseContainerSupport -XX:+IdleTuningCompactOnIdle -XX:+IdleTuningGcOnIdle \
3131
-Xdump:none -Xdump:tool:events=systhrow+throw,filter=*OutOfMemoryError,exec="kill -9 %pid" \
3232
-Dlog4j.configuration=file:///$JDBC_BRIDGE_HOME/log4j.properties -Dnashorn.args=--language=es6 \
33-
${JDBC_BRIDGE_JVM_OPTS:=""} -jar clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION.jar
33+
${JDBC_BRIDGE_JVM_OPTS:=""} -jar clickhouse-jdbc-bridge-$JDBC_BRIDGE_VERSION-shaded.jar
3434
fi
3535
}
3636

misc/perf-test/jdbc-bridge/config/datasources/mariadb.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.0/mariadb-java-client-2.7.0.jar"
66
],
77
"driverClassName": "org.mariadb.jdbc.Driver",
8-
"jdbcUrl": "jdbc:mariadb://mariadb:3306/test?useSSL=false&useCompression=false",
8+
"jdbcUrl": "jdbc:mariadb://mariadb:3306/test?useSSL=false&useCompression=false&rewriteBatchedStatements=true",
99
"dataSource": {
1010
"user": "root",
1111
"password": "root"

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
<packageDescription>JDBC bridge for ClickHouse. It acts as a stateless proxy passing queries from ClickHouse to external datasources.</packageDescription>
241241
<createSymLinks>true</createSymLinks>
242242
<createIncludeFiles>false</createIncludeFiles>
243-
<excludeAllArtifacts>false</excludeAllArtifacts>
243+
<excludeAllArtifacts>true</excludeAllArtifacts>
244244
<excludeAllDependencies>true</excludeAllDependencies>
245245
<libDirectory>/usr/local/lib/java</libDirectory>
246246
<useDefaultCopyResources>false</useDefaultCopyResources>
@@ -327,11 +327,11 @@
327327
<groupname>root</groupname>
328328
<sources>
329329
<source>
330-
<location>target/clickhouse-jdbc-bridge-${project.version}.jar</location>
330+
<location>target/clickhouse-jdbc-bridge-${project.version}-shaded.jar</location>
331331
</source>
332332
<softlinkSource>
333-
<location>/usr/local/lib/java/clickhouse-jdbc-bridge-${project.version}.jar</location>
334-
<destination>clickhouse-jdbc-bridge.jar</destination>
333+
<location>/usr/local/lib/java/clickhouse-jdbc-bridge-${project.version}-shaded.jar</location>
334+
<destination>clickhouse-jdbc-bridge-shaded.jar</destination>
335335
</softlinkSource>
336336
</sources>
337337
</mapping>
@@ -513,7 +513,7 @@
513513
<artifactId>maven-shade-plugin</artifactId>
514514
<version>${shade-plugin.version}</version>
515515
<configuration>
516-
<shadedArtifactAttached>false</shadedArtifactAttached>
516+
<shadedArtifactAttached>true</shadedArtifactAttached>
517517
<createDependencyReducedPom>true</createDependencyReducedPom>
518518
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
519519
<shadedClassifierName>shaded</shadedClassifierName>

src/main/bin/clickhouse-jdbc-bridge

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ init_env() {
4343

4444
start_server() {
4545
# override below environment variables as needed in $INIT_SCRIPT
46-
: ${APP_PACKAGE:="/usr/local/lib/java/clickhouse-jdbc-bridge.jar"}
46+
: ${APP_PACKAGE:="/usr/local/lib/java/clickhouse-jdbc-bridge-shaded.jar"}
4747
: ${JVM_ARGS:="-Xmx512m"}
4848
: ${WORK_DIRECTORY:=$(dirname "$INIT_SCRIPT")}
4949

@@ -61,7 +61,7 @@ start_server() {
6161
fi
6262

6363
echo "Work directory is set to [$WORK_DIRECTORY]"
64-
64+
cd "$WORK_DIRECTORY"
6565
java $JVM_ARGS -Dlog4j.configuration=file:///$WORK_DIRECTORY/log4j.properties \
6666
-Duser.dir="$WORK_DIRECTORY" -jar "$APP_PACKAGE"
6767
}

0 commit comments

Comments
 (0)