-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): Update ClickHouse SQL driver to v2 #16423
base: master
Are you sure you want to change the base?
Conversation
f1c28d0
to
f797456
Compare
80069ac
to
d6a09dd
Compare
d6a09dd
to
3c523dd
Compare
5cd941f
to
d2682fd
Compare
a5cd7e3
to
d2682fd
Compare
@AndreKR do current |
No, I don't think so. The main difference is that in v1 |
Do you see some way of converting old DSNs? Maybe DSNs can be converted by parsing them with the v1 parser and (if successful) then create a v2 DSN from it? I'm asking because Telegraf cannot do these kind of breaking changes, therefore we need to find a way to keep the old configs (and thus DSNs) working... |
Yes, I think that would be possible. I'll prepare something. |
58bd017
to
88fce4f
Compare
@srebhan I have added code that converts parameters in the DSN that have been renamed or have a different format to their v2 equivalents. A warning is logged for each legacy parameter. A number of parameters ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AndreKR for the amazing work! I have some comments in the code...
Additionally, did you test that the conversion function leaves newer v2 DSNs unchanged? Would be good to get some testing there...
Last but not least, please also add a note in the Important Changes
section of the Changelog
about the change, something like
- PR [#16423](https://github.com/influxdata/telegraf/pull/16423) converts the clickhouse drivers to the v2 version.
This new version also requires a [new format for the DSN](url). The plugin tries
its best to convert the old DSN to the new format but might not be able to do so.
Please check for warnings in your log file and convert to the new format as soon
as possible
plugins/outputs/sql/sample.conf
Outdated
@@ -18,6 +18,7 @@ | |||
## {TABLE} - table name as a quoted identifier | |||
## {TABLELITERAL} - table name as a quoted string literal | |||
## {COLUMNS} - column definitions (list of quoted identifiers and types) | |||
## {TAG_COLUMNS} - tag column definitions (list of quoted identifiers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this from this PR as this is an unrelated feature!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to a separate PR.
Please note that without this fix, the SQL output plugin simply does not work with the recommended ClickHouse config, neither with v1 nor with v2. The only reason the existing test doesn't catch this is because the test overrides the create table template.
format](https://github.com/ClickHouse/clickhouse-go/tree/v1.5.4#dsn) than its | ||
newer `v2.*` version. | ||
Note that even when the DSN is specified as `https://` the `secure=true` | ||
parameter is still required. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a warning here that the DSN now should adhere to the v2
schema including a link to how a DSN might be constructed? Furthermore, add a brief note about the fact that
The plugin tries to convert v1 DSNs to v2 but as both schemata are not fully equivalent some parameters might not work anymore. Please check for warnings in your log file and refer to the DSN v2 documentation for available options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -353,7 +353,6 @@ func TestClickHouseIntegration(t *testing.T) { | |||
WaitingFor: wait.ForAll( | |||
wait.NewHTTPStrategy("/").WithPort(nat.Port("8123")), | |||
wait.ForListeningPort(nat.Port(servicePort)), | |||
wait.ForLog("Saved preprocessed configuration to '/var/lib/clickhouse/preprocessed_configs/users.xml'").WithOccurrence(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you absolutely sure the server is fully up, including data being inserted to the database and the server is accepting queries? If not, this can be racy and we end up with flaky tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I took another look and indeed it looks like opening the ports is the very last step in the initialization, long after init.sql has run. We could theoretically wait for the corresponding log output...
2025.02.01 23:37:37.879571 [ 1 ] {} <Information> Application: Listening for http://0.0.0.0:8123
2025.02.01 23:37:37.880204 [ 1 ] {} <Information> Application: Listening for native protocol (tcp): 0.0.0.0:9000
2025.02.01 23:37:37.880607 [ 1 ] {} <Information> Application: Listening for MySQL compatibility protocol: 0.0.0.0:9004
2025.02.01 23:37:37.881120 [ 1 ] {} <Information> Application: Listening for PostgreSQL compatibility protocol: 0.0.0.0:9005
2025.02.01 23:37:37.881492 [ 1 ] {} <Information> Application: Ready for connections.
But since this would be completely equivalent to just waiting for the port to be open, I don't think it would be useful.
b686961
to
6aa4837
Compare
This updates the clickhouse SQL driver for the SQL output plugin to v2. This keeps some compatibility with v1 DSNs by converting parameters from the v1 to the v2 format while logging a warning. Some parameters are no longer supported, those are removed while logging a warning as well.
6aa4837
to
d73a52e
Compare
I had a test about leaving a v2 URL untouched, I have added another one for a v2 URL containing parameters that would be changed if they had incompatible values but they have already compatible values.
Done. |
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
Summary
This updates the clickhouse SQL driver (and its dependencies) to v2.
This is mainly because the v1 driver doesn't support the HTTP protocol, but it also helps with some issues regarding DSN parsing that v1 suffers from.
This includes another commit that changes the default
TableTemplate
so that it works with ClickHouse. Previously everyone who wanted to use ClickHouse had to overrideTableTemplate
.Checklist
Related issues
resolves #16422