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

r2dbc module is added. #914

Merged
merged 2 commits into from
Sep 11, 2022
Merged

r2dbc module is added. #914

merged 2 commits into from
Sep 11, 2022

Conversation

rernas35
Copy link
Contributor

@rernas35 rernas35 commented May 2, 2022

No description provided.

@CLAassistant
Copy link

CLAassistant commented May 2, 2022

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented May 2, 2022

Benchmark                                (client)  (connection)  (statement)  (type)   Mode  Cnt     Score    Error  Units
Basic.insertOneRandomNumber  clickhouse-http-jdbc         reuse       normal  object  thrpt   20   261.588 ± 24.470  ops/s
Basic.insertOneRandomNumber  clickhouse-http-jdbc         reuse     prepared  object  thrpt   20   246.439 ± 30.610  ops/s
Basic.insertOneRandomNumber  clickhouse-http-jdbc           new       normal  object  thrpt   20   269.055 ± 25.420  ops/s
Basic.insertOneRandomNumber  clickhouse-http-jdbc           new     prepared  object  thrpt   20   249.802 ± 22.271  ops/s
Basic.insertOneRandomNumber  clickhouse-grpc-jdbc         reuse       normal  object  thrpt   20   271.438 ± 37.502  ops/s
Basic.insertOneRandomNumber  clickhouse-grpc-jdbc         reuse     prepared  object  thrpt   20   240.271 ± 20.264  ops/s
Basic.insertOneRandomNumber  clickhouse-grpc-jdbc           new       normal  object  thrpt   20   271.611 ± 38.994  ops/s
Basic.insertOneRandomNumber  clickhouse-grpc-jdbc           new     prepared  object  thrpt   20   228.747 ± 32.263  ops/s
Basic.selectOneRandomNumber  clickhouse-http-jdbc         reuse       normal  object  thrpt   20  1045.156 ± 75.673  ops/s
Basic.selectOneRandomNumber  clickhouse-http-jdbc         reuse     prepared  object  thrpt   20  1078.172 ± 86.075  ops/s
Basic.selectOneRandomNumber  clickhouse-http-jdbc           new       normal  object  thrpt   20  1112.164 ± 90.219  ops/s
Basic.selectOneRandomNumber  clickhouse-http-jdbc           new     prepared  object  thrpt   20  1133.879 ± 92.128  ops/s
Basic.selectOneRandomNumber  clickhouse-grpc-jdbc         reuse       normal  object  thrpt   20   929.353 ± 50.465  ops/s
Basic.selectOneRandomNumber  clickhouse-grpc-jdbc         reuse     prepared  object  thrpt   20   941.641 ± 42.785  ops/s
Basic.selectOneRandomNumber  clickhouse-grpc-jdbc           new       normal  object  thrpt   20   919.707 ± 77.469  ops/s
Basic.selectOneRandomNumber  clickhouse-grpc-jdbc           new     prepared  object  thrpt   20   921.545 ± 74.374  ops/s

@zhicwu zhicwu changed the base branch from master to develop May 2, 2022 09:39
@zhicwu
Copy link
Contributor

zhicwu commented May 2, 2022

Thank you @rernas35! Just some immediate feedback:

  1. Is JDK 11 a hard requirement? Can we stay on JDK 8?
  2. Least dependency - can we remove optional dependencies like lombok and slf4j? com.clickhouse.client.logging.Logger can be used for logging - it falls back to java util logging when slf4j is not available.
  3. Can we merge clickhouse-r2dbc-runtime-test into clickhouse-r2dbc?
  4. Bump R2DBC to 1.0.0.RELEASE? - see R2DBC 1.0 goes GA

There're some other minor issues in pom files but once you fixed build break and tidy up code, I can follow up to address them.

@zhicwu zhicwu linked an issue May 2, 2022 that may be closed by this pull request
@rernas35 rernas35 force-pushed the r2dbc_feature branch 7 times, most recently from d9a6f24 to 620195c Compare May 4, 2022 18:41
@linghengqian
Copy link

Is the failure of the CI/CD expected behavior or does it mean that the PR has not yet completed? Is there any unfinished business?

@rernas35
Copy link
Contributor Author

Is the failure of the CI/CD expected behavior or does it mean that the PR has not yet completed? Is there any unfinished business?

can you please approve the workflows

@rernas35
Copy link
Contributor Author

Is the failure of the CI/CD expected behavior or does it mean that the PR has not yet completed? Is there any unfinished business?

builds fixed

@mzitnik
Copy link
Contributor

mzitnik commented Jun 25, 2022

@rernas35 i see this pr is still pending
can you explain shorty what is the purpose of the new module

@rernas35
Copy link
Contributor Author

@rernas35 i see this pr is still pending can you explain shorty what is the purpose of the new module

this is r2dbc module which is compliant with r2dbc specs (https://r2dbc.io/). I need to add a sample and readme then it is ready for review

@zhicwu zhicwu added this to the 0.3.3 release milestone Jun 26, 2022
@zhicwu
Copy link
Contributor

zhicwu commented Jun 26, 2022

Hi @rernas35, it looks like the test never ran. The build success only proves that r2dbc module can be compiled without issue. I think it's better to enable tests and merge it into 0.3.3 release.

Copy link
Contributor

@zhicwu zhicwu left a comment

Choose a reason for hiding this comment

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

Can we also move clickhouse-r2dbc-samples to examples directory?

clickhouse-r2dbc/pom.xml Outdated Show resolved Hide resolved
clickhouse-r2dbc/pom.xml Outdated Show resolved Hide resolved
clickhouse-r2dbc/pom.xml Outdated Show resolved Hide resolved
clickhouse-r2dbc/pom.xml Outdated Show resolved Hide resolved
clickhouse-r2dbc/pom.xml Outdated Show resolved Hide resolved
clickhouse-r2dbc/pom.xml Show resolved Hide resolved
clickhouse-r2dbc/pom.xml Outdated Show resolved Hide resolved
@zhicwu
Copy link
Contributor

zhicwu commented Jun 27, 2022

@rernas35, please use ClickHouseNodes.of(uri) to get list of servers to connect to, since load balancing and failover are now supported(details at here). Please pay attention to failover, it's implemented by a wrapper around ClickHouseClient - see implementation at here. If you don't want the wrapper, you have to explicitly disable agent when build ClickHouseClient, for example: ClickHouseClient.builder().agent(false)...build().

@rernas35 rernas35 force-pushed the r2dbc_feature branch 5 times, most recently from 6791f9b to 50bc36c Compare July 17, 2022 08:26
@rernas35
Copy link
Contributor Author

@rernas35, please use ClickHouseNodes.of(uri) to get list of servers to connect to, since load balancing and failover are now supported(details at here). Please pay attention to failover, it's implemented by a wrapper around ClickHouseClient - see implementation at here. If you don't want the wrapper, you have to explicitly disable agent when build ClickHouseClient, for example: ClickHouseClient.builder().agent(false)...build().

@zhicwu I have done some tests but it looks like r2dbc url is not supporting multiple hosts currently.

here

Since currently fragment part of r2dbc url is not supported, tags are not supported but other parameters are all passed and ClickHouseNodes is being used.

@rernas35
Copy link
Contributor Author

@rernas35 i see this pr is still pending can you explain shorty what is the purpose of the new module

this is r2dbc module which is compliant with r2dbc specs (https://r2dbc.io/). I need to add a sample and readme then it is ready for review

resolved

@rernas35
Copy link
Contributor Author

@rernas35 i see this pr is still pending can you explain shorty what is the purpose of the new module

this module will enable client to use clickhouse-jdbc functionality in a r2dbc compliant way

@rernas35 rernas35 force-pushed the r2dbc_feature branch 2 times, most recently from 5af2de5 to 14f931f Compare July 24, 2022 21:49
@rernas35 rernas35 force-pushed the r2dbc_feature branch 2 times, most recently from 4854205 to 49976f2 Compare September 4, 2022 08:43
@rernas35 rernas35 force-pushed the r2dbc_feature branch 4 times, most recently from 41e1afc to 4bb1bea Compare September 5, 2022 08:54
@zhicwu
Copy link
Contributor

zhicwu commented Sep 7, 2022

Thank you @rernas35, really appreciate your efforts on this. Will review this in the coming weekend and merge it into develop if no critical issues.

Copy link
Contributor

@zhicwu zhicwu left a comment

Choose a reason for hiding this comment

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

A few more feedback(just for documentation):

  • needs a place to close ClickHouseResponse in case query was cancelled etc.
  • exception handling should be improved
  • exception when using grpc - try mvn -Dprotocol=grpc clean verify
  • test/resources can be safely removed as it's included in clickhouse-client test-jar
  • rename examples directory to r2dbc for consistency
  • may remove apache commons dependency

</dependency>
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be restricted to test scope

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Declare version as property

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be failsafe plugin as it's integration test


private static final ClickHouseFormat PREFERRED_FORMAT = ClickHouseFormat.TabSeparatedWithNamesAndTypes;
private ClickHouseRequest<?> request;
List<String> sqlList = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Add private final?

Comment on lines +89 to +91
if (isHttp()) {
req = req.set("send_progress_in_http_headers", 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is no longer required since ClickHouse 22.6 - see #947

Comment on lines 21 to 24
private static final List<String> connQueryParams = Arrays.asList("auto_discovery", "node_discovery_interval",
"node_discovery_limit", "load_balancing_policy", "load_balancing_tags", "health_check_method",
"health_check_interval", "check_all_nodes", "node_check_interval", "node_group_size", "failover",
"retry");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should consider all client options


StringBuilder urlBuilder = new StringBuilder(String.format("%s://%s/%s?user=%s&password=%s", protocol, hosts, database, username, password));
String params = connQueryParams.stream().filter(queryParam -> cfOpt.getValue(Option.valueOf(queryParam)) != null)
.map(queryParam -> String.format("%s=%s", queryParam, cfOpt.getValue(Option.valueOf(queryParam))))
Copy link
Contributor

Choose a reason for hiding this comment

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

URL encode

StringBuilder urlBuilder = new StringBuilder(String.format("%s://%s/%s?user=%s&password=%s", protocol, hosts, database, username, password));
String params = connQueryParams.stream().filter(queryParam -> cfOpt.getValue(Option.valueOf(queryParam)) != null)
.map(queryParam -> String.format("%s=%s", queryParam, cfOpt.getValue(Option.valueOf(queryParam))))
.collect(Collectors.joining("%"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a typo? Should be '&'?

final ClickHouseClient client;
final ClickHouseNode server;

private final String serverVersion = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it's always null?

@BeforeAll
public static void setup() throws Exception {
ClickHouseServerForTest.beforeSuite();
connectionFactory = ConnectionFactories.get(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should support more protocols instead of just http

@zhicwu
Copy link
Contributor

zhicwu commented Sep 11, 2022

@rernas35, no action required. Just document some of the feedback and I'll make changes on your branch shortly to address most of them and then merge. Stay tuned :)

@zhicwu zhicwu merged commit 19ab569 into ClickHouse:develop Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any plans on adding support for r2dbc spec
5 participants