Skip to content
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

Update memsql plugin JDBC driver dependency #11191

Conversation

leveyja
Copy link
Member

@leveyja leveyja commented Feb 25, 2022

Fixes #10669

Description

Update plugin dependency from MariaDB driver to official SingleStore (memsql) driver.

Related issues, pull requests, and links

Documentation

( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.

Release notes

( ) No release notes entries required.
( ) Release notes entries required with the following suggested text:

@cla-bot
Copy link

cla-bot bot commented Feb 25, 2022

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@ebyhr
Copy link
Member

ebyhr commented Feb 25, 2022

We need to update TestingMemSqlServer as well.

By the way, when I tried the official driver 1.0.1 last month, some of the TestMemSqlConnectorTest TestMemSqlTypeMapping failed. Can you run the test in your laptop because the MemSQL CI from forked repository doesn't run.

Comment on lines +62 to +64
<groupId>com.singlestore</groupId>
<artifactId>singlestore-jdbc-client</artifactId>
<version>1.0.1</version>
Copy link
Member

@findepi findepi Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask if a new dependency needed to be vetted or documented somewhere (in our list of open source licenses?).
Btw, the MariaDB driver this is replacing is also LGPL-2.1:
( https://search.maven.org/artifact/org.mariadb.jdbc/mariadb-java-client/2.7.2/jar )
The SingleSource driver is forked from it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the MariaDB driver this is replacing is also LGPL-2.1:

thanks for pointing this out.

I recall some offline discussion with the conclusion that LGPL dependency is OK, but still would prefer @martint to confirm. Will keep 'request for changes' for now here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising it - I have this as a draft as I'm completely new to the process (and the codebase), so all feedback and issues are great for me to be aware of 👍

Copy link
Member

@martint martint Mar 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGPL is ok. GPL is the one that we can't use, unless it has specific exclusions like JDK's Classpath Exception.

@leveyja leveyja force-pushed the leveyja/10669-switch-mariadb-driver-to-singlestore branch from 309c04c to 0ad11fc Compare February 25, 2022 15:37
@cla-bot
Copy link

cla-bot bot commented Feb 25, 2022

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@leveyja
Copy link
Member Author

leveyja commented Feb 25, 2022

We need to update TestingMemSqlServer as well.

By the way, when I tried the official driver 1.0.1 last month, some of the TestMemSqlConnectorTest failed. Can you run the test in your laptop because the MemSQL CI from forked repository doesn't run.

@ebyhr - Once I got the memsql.license I ran the tests locally and they passed 🟢

@leveyja
Copy link
Member Author

leveyja commented Feb 25, 2022

Also - I submitted the [email protected] email 3 days ago - I'll resend it if there was been a problem
Update: This is all good (it's not an automated process)

@github-actions github-actions bot added the docs label Feb 25, 2022
@ebyhr
Copy link
Member

ebyhr commented Feb 25, 2022

@leveyja Sorry, I pasted the wrong test name. Could you confirm TestMemSqlTypeMapping?
Screen Shot 2022-02-26 at 6 57 14

@cla-bot
Copy link

cla-bot bot commented Feb 28, 2022

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@findepi findepi requested a review from hashhar February 28, 2022 16:14
@jhlodin
Copy link
Contributor

jhlodin commented Feb 28, 2022

Will users who currently specify the mariadb connection URL need to update?
Need to update the documentation here and possibly include a release note to inform users about the change - https://trino.io/docs/current/connector/memsql.html#configuration

@@ -623,16 +623,16 @@ protected boolean isSupportedJoinCondition(JdbcJoinCondition joinCondition)
}

String typeName = typeHandle.getJdbcTypeName().get();
if (typeName.equalsIgnoreCase("tinyint unsigned")) {
if (typeName.equalsIgnoreCase("tinyint(3) unsigned")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it instead possible to create the proper JdbcTypeHandle for such columns in JdbcClient#getColumns? See for example how Postgres overrides that to fill in information about array types.

This seems prone to breakage and I'm not sure if this depends on the exact server and driver versions being used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't possible to do then I suggest we drop this migration for now.

I'm of the opinion that if switching the driver isn't bringing any benefits at the moment then we should stick with the mariadb driver for now.
I looked at the current diff and don't see any improvements to consider the switch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hashhar - I had a questions with @wendigo about whether this list is exhaustive or not (I look in their source and I see tinyint(1)->tinyint(4), so I expect it is not). I agree it's fragile and could fail unexpectedly unless we had coverage of all possible types.
I'll look at the JdbcTypeHandle/Postgress client.getColumns - thanks for the suggestion!
(Whether we postpone the change or not, at least this is a useful learning experience for me! 👍 )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the issues with the change to the connection string (thanks @jhlodin for raising that), it looks like a bigger change than originally envisioned, and for very little benefit (as you say, their current driver doesn't add much, and complicates the column mapping - future versions may change further, etc).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can revisit this PR in the future once their driver matures a bit. WDYT @wendigo ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update / clarification: I'm going to attempt to update the type mapping as suggested, along with making jdbc:mariadb urls work transparently (that's already done w/tests, etc).
I may close this PR + re-open a new one though - so shout if I should do that! 👍

@leveyja
Copy link
Member Author

leveyja commented Mar 1, 2022

Will users who currently specify the mariadb connection URL need to update? Need to update the documentation here and possibly include a release note to inform users about the change - https://trino.io/docs/current/connector/memsql.html#configuration

@jhlodin - The docs are generated from the repo, and the source of that doc was updated in the PR: see https://github.com/trinodb/trino/blob/d05536e90fc585cd5f61a1cf52ce28af363cd65a/docs/src/main/sphinx/connector/memsql.rst
(Sphinx generates the doc html from the markup in these rst files).

Re: Will users have to update the connection URL - I just did a quick test, and yes - they would need to update the URL if we go ahead and change our underlying driver to the singlestore driver - (unless we have a layer where we could 's/mariadb/singlestore/g' to the connection string within the MemSQL plugin? But that seems brittle).

In a case like this, where changing our driver would break consumers, do we have a preferred way of handling it? e.g., introduce a new setting to "update.mariadb.connection.to.singlestore=true" by default (and documenting that users should update their connection strings?).

@leveyja leveyja force-pushed the leveyja/10669-switch-mariadb-driver-to-singlestore branch from d05536e to c6ba520 Compare March 2, 2022 16:51
@cla-bot
Copy link

cla-bot bot commented Mar 2, 2022

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@@ -378,6 +382,46 @@ private static RemoteTableName getRemoteTable(ResultSet resultSet)
return Optional.empty();
}

public static ColumnMapping memsqlTimeColumnMapping(TimeType timeType) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore this WIP / exploratory attempt to fix singlestore wrapping LocalTime types.
I may close this PR + open a new one when it's ready - there's a lot of work still to do to clean this up and test it.
CC: @wendigo @hashhar

@@ -55,8 +57,14 @@ public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, C

return new DriverConnectionFactory(
new Driver(),
config.getConnectionUrl(),
ensureUrlBackwardCompatibility(config.getConnectionUrl()),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed our config is mutable: so while config.getConnectionUrl() would still return "jdbc:mariadb", it would be possible to call config.setConnectionUrl(...), but this seems like it would cause impossible to diagnose issues (e.g., depending on when the Module is created, other components may have already "taken a copy" of the original url).

Should we create an ImmutableConfig wrapper around the config (override all .set methods w/throws UnsupportedOperationException("config is immutable")) to make sure it isn't changing after a certain point in the startup lifecycle?

@cla-bot cla-bot bot added the cla-signed label Mar 3, 2022
@leveyja
Copy link
Member Author

leveyja commented Mar 3, 2022

Closing in favour of new non-draft PR - #11301

@leveyja leveyja closed this Mar 3, 2022
@leveyja leveyja deleted the leveyja/10669-switch-mariadb-driver-to-singlestore branch March 3, 2022 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Switch SingleStore (memsql) JDBC driver from MariaDB to official driver
6 participants