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

Dev Services not enabled given Installed features: [cdi, jdbc-postgresql, kotlin, rest, smallrye-context-propagation, vertx] #43428

Closed
laurentperez opened this issue Sep 21, 2024 · 7 comments · Fixed by #43685
Labels
area/devservices area/jdbc Issues related to the JDBC extensions kind/question Further information is requested triage/needs-decision This issue proposes a design change. Needs to be discussed in the ML
Milestone

Comments

@laurentperez
Copy link
Contributor

laurentperez commented Sep 21, 2024

Describe the bug

Hello

I'm using straight SQL statements and resultsets using direct JDBC driver queries : no JOOQ, no Hibernate, no Panache, etc.

I was expecting quarkus dev to use a dev service when I added the quarkus-jdbc-extension per https://quarkus.io/guides/databases-dev-services.

My application.properties is empty per cat src/main/resources/application.properties has no JDBC URL configured so I believe it should have started a dev services container.

It did not.

Expected behavior

a postgres dev services container should have started when quarkus dev was launched

Actual behavior

per dev UI : You do not have any Dev Services running.

per docker ps : no postgres testcontainers container started

image

How to Reproduce?

quarkus create --kotlin --gradle
quarkus extension add quarkus-jdbc-postgresql
quarkus extension add rest-jackson
quarkus dev
2024-09-21 20:38:13,199 INFO  [io.quarkus] (Quarkus Main Thread) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.14.4) started in 3.179s. Listening on: http://localhost:8080

2024-09-21 20:38:13,203 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2024-09-21 20:38:13,203 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, jdbc-postgresql, kotlin, rest, smallrye-context-propagation, vertx]

Output of uname -a or ver

No response

Output of java -version

java 21

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@laurentperez laurentperez added the kind/bug Something isn't working label Sep 21, 2024
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/context-propagation area/devservices area/jdbc Issues related to the JDBC extensions area/kotlin area/smallrye area/vertx labels Sep 21, 2024
Copy link

quarkus-bot bot commented Sep 21, 2024

/cc @FroMage (context-propagation), @Ladicek (arc,smallrye), @barreiro (jdbc), @geoand (devservices,kotlin), @jmartisk (smallrye), @manovotn (arc,context-propagation), @mkouba (arc), @phillip-kruger (smallrye), @radcortez (smallrye), @stuartwdouglas (devservices), @yrodiere (jdbc)

@mkouba mkouba removed area/arc Issue related to ARC (dependency injection) area/context-propagation labels Sep 23, 2024
@FroMage
Copy link
Member

FroMage commented Sep 23, 2024

Perhaps this is only done when we detect that Hibernate runs, which is only done when we have at least one @Entity?

@geoand
Copy link
Contributor

geoand commented Sep 23, 2024

Try injecting the javax.sql.DataSource somewhere in your code - there is a chance that will enable it

@yrodiere
Copy link
Member

The dev services are provided only when quarkus-agroal is in the classpath, because that's the extension that provides a concept of (JDBC) datasources, which dev services can then insert themselves in.
So just running this will solve your problem:

quarkus ext add agroal

Now, why do you even need to run this? Well, weirdly, quarkus-jdbc-postgresql depends on quarkus-agroal only optionally:

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal</artifactId>
<optional>true</optional>
</dependency>

So goes for at least some (probably all) other drivers -- I checked h2. I am unsure if there is a reason for that -- do we want to provide a way for people to use JDBC drivers without defining datasources? Does that even make sense?

I would personally be in favor of adding a mandatory dependency to Agroal in all our JDBC driver extensions, because I am not aware of any documented use case for using JDBC drivers without Agroal.

If, on the other hand, we leave things as they are, I think we should update the documentation (https://quarkus.io/guides/datasource, https://quarkus.io/guides/databases-dev-services) to mention that most of those guides assume that you use Agroal when you use JDBC drivers. Good luck explaining that concisely and in such a way that nobody will miss it :/

@yrodiere yrodiere added triage/needs-decision This issue proposes a design change. Needs to be discussed in the ML and removed triage/needs-feedback We are waiting for feedback. labels Sep 24, 2024
@gsmet
Copy link
Member

gsmet commented Sep 24, 2024

Yeah, I stumbled upon this recently too and found the behavior surprising. I wanted to discuss it with you and then forgot.

I think the initial intent was that you might want to use the JDBC drivers with other connection pooling solutions (HikariCP comes to mind).

I'm not really sure how practical it would be for someone to come up with an extension for another pooling solution in the Quarkiverse. If we are already too tied to Agroal for it to happen, we could probably go one step further.

@yrodiere
Copy link
Member

yrodiere commented Sep 24, 2024

FWIW a quick search through the Quarkiverse org didn't reveal any DB connection pool.

Anyway, I'm pretty sure the dependency to Agroal is all over the place; the Hibernate ORM extension for example has hard dependencies on Agroal.

So, unless someone objects, +1 to depend on Agroal from JDBC driver extensions.

@laurentperez
Copy link
Contributor Author

Nice catch guys ;) thank you

For more context information : I'm using quarkus + DuckDB. Duck does not require a postgres JDBC driver, it uses libpq C driver.

However, Duck can attach to postgres, which is my use case. as in https://duckdb.org/2024/01/26/multi-database-support-in-duckdb.html. pooling is in, its pooling is handheld in https://github.com/duckdb/postgres_scanner/blob/main/src/storage/postgres_connection_pool.cpp

I was expecting a postgres dev service to boot up simply to avoid booting one up using a dedicated docker-compose yaml under dev or test.

Sadly HikariCP has no quarkiverse extension obv. because Quarkus is tied to Agroal, plus people switching from other fwks (where either Hikari or legacy C3PO were used), well, migrate the pooling to Agroal.

@gsmet gsmet added kind/question Further information is requested and removed kind/bug Something isn't working labels Oct 1, 2024
laurentperez added a commit to laurentperez/quarkus that referenced this issue Oct 6, 2024
…o be fire up when any JDBC driver is provided
laurentperez added a commit to laurentperez/quarkus that referenced this issue Oct 7, 2024
…o be fire up when any JDBC driver is provided
laurentperez added a commit to laurentperez/quarkus that referenced this issue Oct 8, 2024
…o be fire up when any JDBC driver is provided
yrodiere added a commit to laurentperez/quarkus that referenced this issue Oct 9, 2024
…o be fire up when any JDBC driver is provided

fix H2 cycling dep and graph for other rdbms

do not let quarkus-reactive-oracle-client pull agroal by itself

Update extensions/reactive-oracle-client/deployment/pom.xml

Co-authored-by: Yoann Rodière <yoann@hibernate.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devservices area/jdbc Issues related to the JDBC extensions kind/question Further information is requested triage/needs-decision This issue proposes a design change. Needs to be discussed in the ML
Projects
None yet
6 participants