-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Support config reactive datasource with list of database urls for fault tolerance and load balance #31994
Support config reactive datasource with list of database urls for fault tolerance and load balance #31994
Conversation
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.
Thank you @benstonezhang
@@ -23,10 +24,10 @@ public class DataSourceReactiveRuntimeConfig { | |||
public boolean cachePreparedStatements = false; | |||
|
|||
/** | |||
* The datasource URL. | |||
* The datasource URLs. |
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.
Can you please add a comment explaining that if multiple values are set, then the pool will be configured to create new connections using each of the urls, in a round-robin fashion?
@@ -112,7 +112,7 @@ private OracleConnectOptions toOracleConnectOptions(DataSourceRuntimeConfig data | |||
DataSourceReactiveOracleConfig dataSourceReactiveOracleConfig) { | |||
OracleConnectOptions oracleConnectOptions; | |||
if (dataSourceReactiveRuntimeConfig.url.isPresent()) { | |||
String url = dataSourceReactiveRuntimeConfig.url.get(); | |||
String url = dataSourceReactiveRuntimeConfig.url.get().get(0); |
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.
Can you please log a warning if the user provides two or more urls for Oracle?
@@ -25,6 +27,6 @@ interface Input { | |||
|
|||
PoolOptions poolOptions(); | |||
|
|||
DB2ConnectOptions db2ConnectOptions(); | |||
List<DB2ConnectOptions> db2ConnectOptionsList(); |
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.
For DB2, we should do the same as with Oracle (only log a warning if the user provides two or more urls).
@@ -25,6 +27,6 @@ interface Input { | |||
|
|||
PoolOptions poolOptions(); | |||
|
|||
MSSQLConnectOptions msSQLConnectOptions(); | |||
List<MSSQLConnectOptions> msSQLConnectOptionsList(); |
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.
For SQL Server, we should do the same as with Oracle (only log a warning if the user provides two or more urls).
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class MySQLPoolLoadBalanceTest { |
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.
Can you add a test for PostgreSQL too?
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.
revised, please check.
For DB2 and SQL Server, as the Reactive DB2 Client and Reactive MSSQL Client documented, Vert.x do support advanced pool configuration:
DB2Pool pool = DB2Pool.pool(Arrays.asList(server1, server2, server3), options);
MSSQLPool pool = MSSQLPool.pool(Arrays.asList(server1, server2, server3), options);
so I think we should support it too.
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.
Thank you for the updates. Yes, in the Vert.x API / documentation it is possible but, in practice, I'm aware of multi-master systems only for MySQL, Postgres and Oracle.
For Oracle we can't support it the same way because the driver has to take care of it.
String url = dataSourceReactiveRuntimeConfig.url.get().get(0); | ||
List<String> urls = dataSourceReactiveRuntimeConfig.url.get(); | ||
if (urls.size() > 1) { | ||
log.warn("The Oracle driver does not support multiple URLs. This first is used, and others is ignored."); |
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.
log.warn("The Oracle driver does not support multiple URLs. This first is used, and others is ignored."); | |
log.warn("The Reactive Oracle Client does not support multiple URLs. The first one will be used, and others will be ignored."); |
I'm not family with DB2 and SQL Server. I will rework it tomorrow. |
Thank you
|
…he ReactiveDialectWrapper
Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](mariadb-corporation/mariadb-connector-j@3.1.2...3.1.3) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps `smallrye-open-api.version` from 3.3.0 to 3.3.1. Updates `smallrye-open-api-core` from 3.3.0 to 3.3.1 - [Release notes](https://github.com/smallrye/smallrye-open-api/releases) - [Commits](smallrye/smallrye-open-api@3.3.0...3.3.1) Updates `smallrye-open-api-jaxrs` from 3.3.0 to 3.3.1 Updates `smallrye-open-api-spring` from 3.3.0 to 3.3.1 Updates `smallrye-open-api-vertx` from 3.3.0 to 3.3.1 Updates `smallrye-open-api-ui` from 3.3.0 to 3.3.1 --- updated-dependencies: - dependency-name: io.smallrye:smallrye-open-api-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.smallrye:smallrye-open-api-jaxrs dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.smallrye:smallrye-open-api-spring dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.smallrye:smallrye-open-api-vertx dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.smallrye:smallrye-open-api-ui dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
… specified in datasource url
@tsegismont code updated, please check. Thx. |
Ensure Dialects initialzed by Hibernate Reactive extension use the ReactiveDialectWrapper
Update SmallRye Config to 3.2.0
DevUI: Liquibase
Fix Kotlin formatting
Fix OTel exporter headers config
Allow using the annotation `@PartFilename` on method parameters
…g.mariadb.jdbc-mariadb-java-client-3.1.3 Bump mariadb-java-client from 3.1.2 to 3.1.3
…allrye-open-api.version-3.3.1 Bump smallrye-open-api.version from 3.3.0 to 3.3.1
Can you please rebase your PR rather than merging the |
… specified in datasource url
…tive-db-conn-pool
🙈 The PR is closed and the preview is expired. |
… specified in datasource url
…ang/quarkus into reactive-db-conn-pool
It doesn't look good @benstonezhang |
just done rebase and push |
✔️ The latest workflow run for the pull request has completed successfully. It should be safe to merge provided you have a look at the other checks in the summary. |
@tsegismont Sorry, seems I had messed this branch. I create a new PR #32128, please check. |
Add support to config load balance urls for reactive datasources in application.properties, for example:
or
The original PR is #31852, which only update reactive mysql client. As @tsegismont suggested, I replaced
public Optional<String> url
withpublic Optional<List<String>> urls
in DataSourceReactiveRuntimeConfig, and all of reactive database client were updated accordingly.There is one exception: Vert.x oracle client already have build-in load balance support, and there is no such function like
OraclePool.pool(Vertx vertx, List<OracleConnectOptions> databases, PoolOptions options)
. So only the first url is valid and others is discarded even if you config more urls.The original PR title maybe improperly and misleading, so I create this one.