Skip to content

Commit 4be9527

Browse files
authored
Merge pull request #893 from Altinity/867-potential-connection-leak-in-createconnection-method
Use Hikari Connection Pool for handling Clickhouse connections
2 parents 8bf2bec + 3f876df commit 4be9527

File tree

111 files changed

+3449
-2526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+3449
-2526
lines changed

.github/workflows/pull-request.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ jobs:
3030
with:
3131
SINK_CONNECTOR_IMAGE: altinityinfra/clickhouse-sink-connector:${{ github.event.number }}-${{ github.sha }}-lt
3232

33+
testflows-lightweight-hikari-pool:
34+
needs: [build-kafka-lightweight]
35+
uses: ./.github/workflows/testflows-sink-connector-lightweight.yml
36+
secrets: inherit
37+
with:
38+
SINK_CONNECTOR_IMAGE: altinityinfra/clickhouse-sink-connector:${{ github.event.number }}-${{ github.sha }}-lt
39+
extra_args: --hikari-pool
40+
artifact_suffix: hikari-pool
41+
3342
java-tests-kafka:
3443
needs: [build-kafka-lightweight]
3544
uses: ./.github/workflows/sink-connector-kafka-tests.yml

.github/workflows/testflows-sink-connector-lightweight.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ on:
1111
package:
1212
description: "Package either 'docker://' or 'https://'. Example: 'https://s3.amazonaws.com/clickhouse-builds/23.3/.../package_release/clickhouse-common-static_23.3.1.64_amd64.deb', or 'docker://altinity/clickhouse-server:23.8.8'"
1313
type: string
14-
default: docker://clickhouse/clickhouse-server:23.3
14+
default: docker://clickhouse/clickhouse-server:23.8
1515
output_format:
1616
description: "Testflows output style."
1717
type: string
1818
default: new-fails
19+
extra_args:
20+
description: "Extra arguments for the tests."
21+
required: false
22+
type: string
23+
default: ""
24+
artifact_suffix:
25+
description: "Artifact sufix"
26+
required: false
27+
type: string
28+
default: ""
1929
secrets:
2030
DOCKERHUB_USERNAME:
2131
required: false
@@ -34,11 +44,16 @@ on:
3444
package:
3545
description: "Package either 'docker://' or 'https://'. Example: 'https://s3.amazonaws.com/clickhouse-builds/23.3/.../package_release/clickhouse-common-static_23.3.1.64_amd64.deb', or 'docker://altinity/clickhouse-server:23.8.8'"
3646
type: string
37-
default: docker://clickhouse/clickhouse-server:23.3
38-
extra_args:
47+
default: docker://clickhouse/clickhouse-server:23.8
48+
suite:
3949
description: "Specific Suite To Run (Default * to run everything)."
4050
required: false
4151
type: string
52+
extra_args:
53+
description: "Extra arguments for the tests."
54+
required: false
55+
type: string
56+
default: ""
4257
custom_run_name:
4358
description: 'Custom run name (optional)'
4459
required: false
@@ -115,7 +130,7 @@ jobs:
115130

116131
- name: Run testflows tests
117132
working-directory: sink-connector-lightweight/tests/integration
118-
run: python3 -u regression.py --only "/mysql to clickhouse replication/auto table creation/${{ inputs.extra_args != '' && inputs.extra_args || '*' }}" --clickhouse-binary-path="${{inputs.package}}" --test-to-end --output ${{ inputs.output_format }} --collect-service-logs --attr project="${GITHUB_REPOSITORY}" project.id="$GITHUB_RUN_NUMBER" user.name="$GITHUB_ACTOR" github_actions_run="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" sink_version="registry.gitlab.com/altinity-public/container-images/clickhouse_debezium_embedded:latest" s3_url="https://altinity-test-reports.s3.amazonaws.com/index.html#altinity-sink-connector/testflows/${{ steps.date.outputs.date }}_${{github.run.number}}/" --log logs/raw.log
133+
run: python3 -u regression.py --only "/mysql to clickhouse replication/auto table creation/${{ inputs.suite != '' && inputs.suite || '*' }}" --clickhouse-binary-path="${{inputs.package}}" --test-to-end ${{ inputs.extra_args != '' && inputs.extra_args || '' }} --output ${{ inputs.output_format }} --collect-service-logs --attr project="${GITHUB_REPOSITORY}" project.id="$GITHUB_RUN_NUMBER" user.name="$GITHUB_ACTOR" github_actions_run="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" sink_version="registry.gitlab.com/altinity-public/container-images/clickhouse_debezium_embedded:latest" s3_url="https://altinity-test-reports.s3.amazonaws.com/index.html#altinity-sink-connector/testflows/${{ steps.date.outputs.date }}_${{github.run.number}}/" --log logs/raw.log
119134

120135
- name: Create tfs results report
121136
if: always()
@@ -139,7 +154,7 @@ jobs:
139154
- uses: actions/upload-artifact@v4
140155
if: always()
141156
with:
142-
name: testflows-sink-connector-lightweight-artefacts
157+
name: testflows-sink-connector-lightweight-artefacts${{ inputs.artifact_suffix != '' && '-' || '' }}${{ inputs.artifact_suffix }}
143158
path: |
144159
sink-connector-lightweight/tests/integration/logs/*.log
145160
sink-connector-lightweight/tests/integration/env/auto/configs/*.yml
@@ -193,7 +208,7 @@ jobs:
193208

194209
- name: Run testflows tests
195210
working-directory: sink-connector-lightweight/tests/integration
196-
run: python3 -u regression.py --only "/mysql to clickhouse replication/auto replicated table creation/${{ inputs.extra_args != '' && inputs.extra_args || '*' }}" --clickhouse-binary-path="${{inputs.package}}" --test-to-end --output ${{ inputs.output_format }} --collect-service-logs --attr project="${GITHUB_REPOSITORY}" project.id="$GITHUB_RUN_NUMBER" user.name="$GITHUB_ACTOR" github_actions_run="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" sink_version="registry.gitlab.com/altinity-public/container-images/clickhouse_debezium_embedded:latest" s3_url="https://altinity-test-reports.s3.amazonaws.com/index.html#altinity-sink-connector/testflows/${{ steps.date.outputs.date }}_${{github.run.number}}/" --log logs/raw.log
211+
run: python3 -u regression.py --only "/mysql to clickhouse replication/auto replicated table creation/${{ inputs.suite != '' && inputs.suite || '*' }}" --clickhouse-binary-path="${{inputs.package}}" --test-to-end ${{ inputs.extra_args != '' && inputs.extra_args || '' }} --output ${{ inputs.output_format }} --collect-service-logs --attr project="${GITHUB_REPOSITORY}" project.id="$GITHUB_RUN_NUMBER" user.name="$GITHUB_ACTOR" github_actions_run="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" sink_version="registry.gitlab.com/altinity-public/container-images/clickhouse_debezium_embedded:latest" s3_url="https://altinity-test-reports.s3.amazonaws.com/index.html#altinity-sink-connector/testflows/${{ steps.date.outputs.date }}_${{github.run.number}}/" --log logs/raw.log
197212

198213
- name: Create tfs results report
199214
if: always()
@@ -217,7 +232,7 @@ jobs:
217232
- uses: actions/upload-artifact@v4
218233
if: always()
219234
with:
220-
name: testflows-sink-connector-lightweight-replicated-artefacts
235+
name: testflows-sink-connector-lightweight-replicated-artefacts${{ inputs.artifact_suffix != '' && '-' || '' }}${{ inputs.artifact_suffix }}
221236
path: |
222237
sink-connector-lightweight/tests/integration/logs/*.log
223238
sink-connector-lightweight/tests/integration/env/auto_replicated/configs/*.yml

doc/Troubleshooting.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ This can be limited by passing this configuration parameter to the JVM:
3333
#N can be 50.
3434
-XX:ParallelGCThreads=<N>.
3535
```
36+
### Caused by: java.sql.BatchUpdateException: Connect to timed out
37+
Set `keepalive.timeout=3` in clickhouse server and make sure
38+
the following configuration
39+
`clickhouse.jdbc.params: "keepalive.timeout=3,max_buffer_size=1000000,socket_timeout=30000,connection_timeout=30000"`
40+
is added to `config.yml`
3641

3742
### Slow startup when replicating Database with high number of tables.
3843
Use the following configuration to limit the number of tables that Debezium would capture in the schema_only mode.
@@ -57,4 +62,4 @@ https://stackoverflow.com/questions/63523998/multiple-debezium-connector-for-one
5762
Make sure to add `slot.name` to the configuration(config.yml) and change it to a unique name.
5863

5964
### PostgreSQL (WAL size growing)
60-
[Handling PostgreSQL WAL Growth with Debezium Connectors](doc/postgres_wal_growth.md)
65+
[Handling PostgreSQL WAL Growth with Debezium Connectors](doc/postgres_wal_growth.md)

sink-connector-lightweight/dependency-reduced-pom.xml

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@
121121
<artifactId>javalin-testtools</artifactId>
122122
<version>5.5.0</version>
123123
<scope>test</scope>
124-
<exclusions>
125-
<exclusion>
126-
<artifactId>okhttp</artifactId>
127-
<groupId>com.squareup.okhttp3</groupId>
128-
</exclusion>
129-
</exclusions>
130124
</dependency>
131125
<dependency>
132126
<groupId>io.debezium</groupId>
@@ -162,10 +156,6 @@
162156
<artifactId>oracle-xe</artifactId>
163157
<groupId>org.testcontainers</groupId>
164158
</exclusion>
165-
<exclusion>
166-
<artifactId>junit-platform-launcher</artifactId>
167-
<groupId>org.junit.platform</groupId>
168-
</exclusion>
169159
<exclusion>
170160
<artifactId>junit-jupiter</artifactId>
171161
<groupId>org.junit.jupiter</groupId>
@@ -174,10 +164,6 @@
174164
<artifactId>quarkus-test-common</artifactId>
175165
<groupId>io.quarkus</groupId>
176166
</exclusion>
177-
<exclusion>
178-
<artifactId>okhttp</artifactId>
179-
<groupId>com.squareup.okhttp3</groupId>
180-
</exclusion>
181167
</exclusions>
182168
</dependency>
183169
<dependency>
@@ -207,7 +193,7 @@
207193
<dependency>
208194
<groupId>org.testcontainers</groupId>
209195
<artifactId>testcontainers</artifactId>
210-
<version>1.19.1</version>
196+
<version>1.20.4</version>
211197
<scope>test</scope>
212198
<exclusions>
213199
<exclusion>
@@ -231,7 +217,7 @@
231217
<dependency>
232218
<groupId>org.testcontainers</groupId>
233219
<artifactId>jdbc</artifactId>
234-
<version>1.19.1</version>
220+
<version>1.20.4</version>
235221
<scope>test</scope>
236222
<exclusions>
237223
<exclusion>
@@ -243,37 +229,37 @@
243229
<dependency>
244230
<groupId>org.testcontainers</groupId>
245231
<artifactId>junit-jupiter</artifactId>
246-
<version>1.19.1</version>
232+
<version>1.20.4</version>
247233
<scope>test</scope>
248234
</dependency>
249235
<dependency>
250236
<groupId>org.testcontainers</groupId>
251237
<artifactId>clickhouse</artifactId>
252-
<version>1.19.1</version>
238+
<version>1.20.4</version>
253239
<scope>test</scope>
254240
</dependency>
255241
<dependency>
256242
<groupId>org.testcontainers</groupId>
257243
<artifactId>mysql</artifactId>
258-
<version>1.19.1</version>
244+
<version>1.20.4</version>
259245
<scope>test</scope>
260246
</dependency>
261247
<dependency>
262248
<groupId>org.testcontainers</groupId>
263249
<artifactId>postgresql</artifactId>
264-
<version>1.19.1</version>
250+
<version>1.20.4</version>
265251
<scope>test</scope>
266252
</dependency>
267253
<dependency>
268254
<groupId>org.testcontainers</groupId>
269255
<artifactId>mariadb</artifactId>
270-
<version>1.19.1</version>
256+
<version>1.20.4</version>
271257
<scope>test</scope>
272258
</dependency>
273259
<dependency>
274260
<groupId>org.testcontainers</groupId>
275261
<artifactId>mongodb</artifactId>
276-
<version>1.19.1</version>
262+
<version>1.20.4</version>
277263
<scope>test</scope>
278264
</dependency>
279265
<dependency>
@@ -289,10 +275,6 @@
289275
<version>5.8.1</version>
290276
<scope>test</scope>
291277
<exclusions>
292-
<exclusion>
293-
<artifactId>junit-platform-engine</artifactId>
294-
<groupId>org.junit.platform</groupId>
295-
</exclusion>
296278
<exclusion>
297279
<artifactId>junit-jupiter-api</artifactId>
298280
<groupId>org.junit.jupiter</groupId>
@@ -317,10 +299,38 @@
317299
<artifactId>junit-jupiter-api</artifactId>
318300
<groupId>org.junit.jupiter</groupId>
319301
</exclusion>
302+
</exclusions>
303+
</dependency>
304+
<dependency>
305+
<groupId>org.junit.platform</groupId>
306+
<artifactId>junit-platform-launcher</artifactId>
307+
<version>1.8.2</version>
308+
<scope>test</scope>
309+
<exclusions>
310+
<exclusion>
311+
<artifactId>apiguardian-api</artifactId>
312+
<groupId>org.apiguardian</groupId>
313+
</exclusion>
314+
</exclusions>
315+
</dependency>
316+
<dependency>
317+
<groupId>org.junit.platform</groupId>
318+
<artifactId>junit-platform-engine</artifactId>
319+
<version>1.8.2</version>
320+
<scope>test</scope>
321+
<exclusions>
322+
<exclusion>
323+
<artifactId>opentest4j</artifactId>
324+
<groupId>org.opentest4j</groupId>
325+
</exclusion>
320326
<exclusion>
321-
<artifactId>junit-platform-launcher</artifactId>
327+
<artifactId>junit-platform-commons</artifactId>
322328
<groupId>org.junit.platform</groupId>
323329
</exclusion>
330+
<exclusion>
331+
<artifactId>apiguardian-api</artifactId>
332+
<groupId>org.apiguardian</groupId>
333+
</exclusion>
324334
</exclusions>
325335
</dependency>
326336
<dependency>
@@ -356,7 +366,7 @@
356366
<properties>
357367
<quarkus.platform.version>2.14.0.Final</quarkus.platform.version>
358368
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
359-
<version.testcontainers>1.19.1</version.testcontainers>
369+
<version.testcontainers>1.20.4</version.testcontainers>
360370
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
361371
<version.kafka>3.8.0</version.kafka>
362372
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker exec -it clickhouse clickhouse-client --database public --final 1

sink-connector-lightweight/docker/config.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ database.server.name: "ER54"
2929

3030
# database.include.list An optional list of regular expressions that match database names to be monitored;
3131
# any database name not included in the whitelist will be excluded from monitoring. By default all databases will be monitored.
32-
database.include.list: test
32+
database.include.list: sbtest
3333

3434
# table.include.list An optional list of regular expressions that match fully-qualified table identifiers for tables to be monitored;
3535
table.include.list: ""
@@ -130,7 +130,7 @@ database.connectionTimeZone: "UTC"
130130

131131
# Configuration to override the clickhouse database name for a given MySQL database name. If this configuration is not
132132
# provided, the MySQL database name will be used as the ClickHouse database name.
133-
clickhouse.database.override.map: "test:ch_test"
133+
#clickhouse.database.override.map: "test:ch_test"
134134

135135
# clickhouse.datetime.timezone: This timezone will override the default timezone of ClickHouse server. Timezone columns will be set to this timezone.
136136
#clickhouse.datetime.timezone: "UTC"
@@ -168,7 +168,7 @@ ignore.ddl.regex: "(?i)(ANALYZE PARTITION).*"
168168
#buffer.max.records: "10000"
169169

170170
# ClickHouse JDBC configuration parameters, as a list of key-value pairs separated by commas.
171-
#clickhouse.jdbc.params: "max_buffer_size=1000000,socket_timeout=10000"
171+
clickhouse.jdbc.params: "keepalive.timeout=3,max_buffer_size=1000000,socket_timeout=30000,connection_timeout=30000"
172172

173173
# Maximum number of threads in the thread pool for processing CDC records.
174174
#thread.pool.size: 10
@@ -179,6 +179,9 @@ ignore.ddl.regex: "(?i)(ANALYZE PARTITION).*"
179179
#Metrics (Prometheus target), required for Grafana Dashboard
180180
metrics.enable: "true"
181181

182+
#connection.pool.disable: "true"
183+
#connection.pool.max.size: 500
184+
182185
# Skip schema history capturing, use the following configuration
183186
# to reduce slow startup when replicating dbs with large number of tables
184187
#schema.history.internal.store.only.captured.tables.ddl: "true"
@@ -189,4 +192,4 @@ use.nongraceful.disconnect: "true"
189192
database.keep.alive.interval.`ms: "30000" #Send keepalive every 30 seconds
190193
database.connection.reconnect.backoff.ms: "1000"
191194
database.connection.reconnect.backoff.max.ms: "10000"
192-
database.ssl.mode: "disabled"
195+
database.ssl.mode: "disabled"

sink-connector-lightweight/docker/config_postgres.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ auto.create.tables: "true"
9393
# database.dbname: The name of the PostgreSQL database from which events are to be captured when not using snapshot mode.
9494
database.dbname: "public"
9595

96+
clickhouse.jdbc.params: "keepalive.timeout=3,max_buffer_size=1000000,socket_timeout=30000,connection_timeout=30000"
97+
9698
# clickhouse.datetime.timezone: This timezone will override the default timezone of ClickHouse server. Timezone columns will be set to this timezone.
9799
#clickhouse.datetime.timezone: "UTC"
98100

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docker exec -it docker_postgres_1 psql -U root public
2+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
docker network create docker_default
4+
docker-compose create mysql-master
5+
docker-compose create clickhouse
6+
docker-compose start mysql-master
7+
docker-compose start clickhouse

sink-connector-lightweight/pom.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<version.debezium>3.0.0.Final</version.debezium>
1717
<version.junit>5.9.1</version.junit>
18-
<version.testcontainers>1.19.1</version.testcontainers>
18+
<version.testcontainers>1.20.4</version.testcontainers>
1919
<version.checkstyle.plugin>3.1.1</version.checkstyle.plugin>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -233,6 +233,11 @@
233233
<!-- <scope>test</scope>-->
234234
</dependency>
235235

236+
<dependency>
237+
<groupId>com.zaxxer</groupId>
238+
<artifactId>HikariCP</artifactId>
239+
<version>6.0.0</version>
240+
</dependency>
236241
<dependency>
237242
<groupId>org.antlr</groupId>
238243
<artifactId>antlr4-runtime</artifactId>
@@ -334,6 +339,18 @@
334339
<scope>test</scope>
335340
</dependency>
336341

342+
<dependency>
343+
<groupId>org.junit.platform</groupId>
344+
<artifactId>junit-platform-launcher</artifactId>
345+
<version>1.8.2</version>
346+
<scope>test</scope>
347+
</dependency>
348+
<dependency>
349+
<groupId>org.junit.platform</groupId>
350+
<artifactId>junit-platform-engine</artifactId>
351+
<version>1.8.2</version>
352+
<scope>test</scope>
353+
</dependency>
337354
<dependency> <!-- necessary for Java 9+ -->
338355
<groupId>org.apache.tomcat</groupId>
339356
<artifactId>annotations-api</artifactId>

0 commit comments

Comments
 (0)