-
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
SqlClient pool migration #46015
SqlClient pool migration #46015
Conversation
@cescoffier @gsmet @yrodiere @geoand @jponge would you mind taking a look at this draft PR? There are a few things I would like to figure out before going on with other extensions. DRYThis is maybe a dumb question. In the processor there is now: private static final DotName VERTX_POOL = DotName.createSimple(Pool.class);
private static final Type VERTX_POOL_TYPE = Type.create(VERTX_POOL, Type.Kind.CLASS); Is it fine to put this somewhere in the Injection of vendor pool typesShould we have a warning message logged to the console when this happens? Implications on Hibernate ReactiveSince both the raw and vendor types can still be injected, I don't believe Hibernate Reactive integration will be impacted. Migration toolingDo we share OpenRewrite rules somewhere? How about adding rules so that users can start migrating now? Datasource Health Check filtering
Mutiny types are not deprecatedBoth Shouldn't we fix this in Vert.x Mutiny bindings? I would expect this to urge users to switch to parent pool types in their codebases. |
cc @DavideD
cc @gsmet
Sure, you can a
cc @jponge |
🙈 The PR is closed and the preview is expired. |
@tsegismont re Mutiny types are not deprecated yes it's something to be considered |
Note that the Likely new bindings generator does honor deprecation annonations. |
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.
Hey,
Thanks, I added a few comments below.
In the processor there is now:
private static final DotName VERTX_POOL = DotName.createSimple(Pool.class); private static final Type VERTX_POOL_TYPE = Type.create(VERTX_POOL, Type.Kind.CLASS);Is it fine to put this somewhere in the
reactive-datasource
extension to avoid duplication?
Not only is it fine, it's great! Every time I touch this code I think "man, so much duplication..."
Injection of vendor pool types
Should we have a warning message logged to the console when this happens? In this case, how about adding the log instruction inside the body of the function defined in
Recorder#vendorPool
andRecorder#mutinyVendorPool
?
I think it's probably enough if the types themselves are deprecated?
But if you want warnings at Quarkus build time or at bootstrap, maybe we should ask @Ladicek / @mkouba / @manovotn. What is the recommended way to mark a bean as "dangerous" and/or have warnings be logged when it's injected/retrieved?
Implications on Hibernate Reactive
Since both the raw and vendor types can still be injected, I don't believe Hibernate Reactive integration will be impacted.
I think Hibernate Reactive uses Pool
already:
Lines 275 to 295 in 3e63622
private void registerVertxAndPool(String persistenceUnitName, | |
RuntimeSettings runtimeSettings, | |
PreconfiguredReactiveServiceRegistryBuilder serviceRegistry) { | |
if (runtimeSettings.isConfigured(AvailableSettings.URL)) { | |
// the pool has been defined in the persistence unit, we can bail out | |
return; | |
} | |
// for now, we only support one pool but this will change | |
String datasourceName = DataSourceUtil.DEFAULT_DATASOURCE_NAME; | |
Pool pool; | |
try { | |
InjectableInstance<Pool> poolHandle = Arc.container().select(Pool.class); | |
if (!poolHandle.isResolvable()) { | |
throw new IllegalStateException("No pool has been defined for persistence unit " + persistenceUnitName); | |
} | |
// ClientProxy.unwrap is necessary to trigger exceptions on inactive datasources | |
pool = ClientProxy.unwrap(poolHandle.get()); | |
} catch (RuntimeException e) { | |
throw PersistenceUnitUtil.unableToFindDataSource(persistenceUnitName, datasourceName, e); | |
} |
Migration tooling
Do we share OpenRewrite rules somewhere? How about adding rules so that users can start migrating now?
https://github.com/quarkusio/quarkus-updates/
Datasource Health Check filtering
ReactivePgDataSourcesHealthCheck
still looks up forPgPool
in Arc. I couldn't think about a solution for selecting pools bound to datasources having the correct db kind. Any ideas?
I'd expect something in the (build-time) processor to take note of which datasources are PostgreSQL datasources, create a List<String>
with the names, and have it passed to ReactivePgDataSourcesHealthCheck
somehow, so it'll retrieve those datasources and those only.
Mutiny types are not deprecated
Both
io.vertx.mutiny.sqlclient.Pool
andio.vertx.mutiny.pgclient.PgPool
aren't deprecated, even though the corresponding Vert.x type are deprecated.Shouldn't we fix this in Vert.x Mutiny bindings?
I would expect this to urge users to switch to parent pool types in their codebases.
+1
...ns/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/PgPoolCreator.java
Show resolved
Hide resolved
...ve-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java
Outdated
Show resolved
Hide resolved
...lient/deployment/src/main/java/io/quarkus/reactive/pg/client/deployment/PgPoolBuildItem.java
Outdated
Show resolved
Hide resolved
Just for the record, you can simplify that to
I don't think we have anything like that. How would we detect that? Application classes would trigger the warning, but non-application classes wouldn't? Would we detect that on beans or on bean types? (As in, some bean types would be OK to use, while others would be "dangerous".) |
Hibernate Reactive doesn't and shouldn't use PgPool, because we support other databases. |
Ladislav is right, there is no facility for that. Only other thing I can think of is monitoring injection points in user app and then logging; I think we had some build item with all injection points? This of course won't detect/include any dynamic resolution ( |
FYI I'm doing a patch release soon of the Vert.x Mutiny bindings, and the fix for deprecation will be in (+ using the relocated Jandex plugin that for some reason we hadn't migrated to) |
Thanks everyone for your comments!
@yrodiere I have the same feeling. Perhaps it's better to address this in a separate PR though.
@yrodiere thanks, I'll try that.
@Ladicek thanks for the tip
@manovotn @Ladicek thanks. Since the Mutiny Vert.x bindings generator will soon be able to mark generated types as deprecated when needed, I won't pursue in this direction.
Thank you @jponge ! |
523c029
to
a68ae4f
Compare
@yrodiere PTAL, in particular to the commit that get rids of vendor pool lookup in |
Yes, there's the |
b1c5e53
to
21ab674
Compare
b922f31
to
e39cd82
Compare
@geoand ^^ |
@tsegismont that's exactly what I had in mind! |
This comment has been minimized.
This comment has been minimized.
Deprecate PgPoolBuildItem for removal Refactor PgPoolCreator producer and processor The PgPoolCreator change will not break existing implementations. Indeed, the contract now uses the parent Pool type, so returning PgPool is fine. In the recorder, the pool configurator now returns the parent Pool type. Then, in the processor, new bean configurators are set up to support injection of the different pools: - bare pool - vendor pool - mutiny pool - mutiny vendor pool Also, we can get rid of vendor pool lookup in ReactivePgDataSourcesHealthCheck. The PgPoolSupport bean indicates which datasource names correspond to a PgPool that has actually been created. It allows to filter Pool bean instances in ReactivePgDataSourcesHealthCheck.
Apply changes from previous commits to the Reactive MySQL Client extension
Apply changes from previous commits to the Reactive MSSQL Client extension
Apply changes from previous commits to the Reactive Oracle Client extension
Apply changes from previous commits to the Reactive DB2 Client extension
This comment has been minimized.
This comment has been minimized.
ad5d2d6
to
a07d65d
Compare
@geoand done, and squashed commits |
Thanks! I'll have another look tomorrow |
Status for workflow
|
Status for workflow
|
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!
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.
LGTM
Thank you guys. Can one of you please merge the PR? |
I'll want to give @gsmet a chance to review if he wants to |
Sorry, late to the party, will have a look this afternoon and hopefully merge it. |
...ent/deployment/src/main/java/io/quarkus/reactive/db2/client/deployment/DB2PoolBuildItem.java
Show resolved
Hide resolved
I merged it for 3.21. A few additional things to do:
|
Follows-up on quarkusio#46015
Thank you @gsmet Here's an update for the migration guide: == Datasources
=== Generic pool class for reactive datasources
In previous versions of Quarkus, there were vendor-specific pool classes for each reactive datasource type:
* `io.vertx.mutiny.db2client.DB2Pool`, for IBM Db2
* `io.vertx.mutiny.mysqlclient.MySQLPool`, for MariaDB/MySQL
* `io.vertx.mutiny.mssqlclient.MSSQLPool`, for Microsoft SQL Server
* `io.vertx.mutiny.oracleclient.OraclePool`, for Oracle
* `io.vertx.mutiny.pgclient.PgPool`, for PostgreSQL.
Starting with this version of Quarkus, you should use the generic pool class, `io.vertx.mutiny.sqlclient.Pool`, regardless of the database vendor. Regarding recipes, changing imports should be fine for all "regular" users, i.e. users injecting a managed reactive pool. |
PgPool
and other vendor pool types are deprecated in Vert.x 4. In Vert.x 5, these types are going away.This PR is an attempt to make the transition incremental. Instead of using
PgPool
and other vendor pool types as the basis for bean creation, we can use thePool
parent type.In the recorder, the pool configurator now returns the parent
Pool
type.Then, in the processor, new bean configurators are set up to support injection of the different pools:
Each commit can be reviewed individually.
Updated extensions: