Hi,Some time ago we received a report [1] that applications that "forget" to set a JDBC URL for a datasource might start and be considered ready/healthy, even though the datasource is not, actually, ready.Applications that use these datasources through a configured Hibernate ORM/Reactive persistence unit actually won't start, because Hibernate checks the datasources are configured for each persistence unit on startup [2].But applications that don't use Hibernate, or that have no configured persistence unit, will indeed start and appear to work well (health checks will report "UP")... except they'll fail to serve any request that involves the datasource.This is quite confusing, and arguably downright dangerous.
Worse, the use cases are scarce. After some thinking, I could only come up with these:
- Some applications may require a particular datasource for some of their endpoints only, and thus developers might want to deploy the application without configuring the datasource.
- We always define a default datasource, so applications that rely exclusively on named datasources would need to start even if the default datasource is not configured.
To get out of the current situation, I would like to suggest that we change this behavior:
- I'm working on [3] to introduce a way to *explicitly* mark a datasource as "inactive" at runtime. This should address the first use case above (and more, but that's beside the point).
- We will no longer define a default datasource at build time if a named datasource is configured, and there is no configuration for the default datasource. This should make sure we don't break the second use case above.
It's also similar to what we do for persistence units in Hibernate ORM/Reactive [4]- If a datasource defined at build time (default or named) is unconfigured at runtime, we'll fail on startup and recommend configuring that datasource or deactivating it.
Item 2 might require some changes in Smallrye Config as it seems a Map using `@WithUnnamedKey` [5] [6] will currently always contain the unnamed key... at least in some cases. Hopefully that's something that can be addressed, but this might delay the change past the 3.7 feature freeze. Which I guess could be a good thing anyway.Back to the proposal: any thoughts, opinions on the general approach?
Thanks,Yoann RodièreHibernate Team
--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/CAEqagprg%2BnWLhp%2BtCDqAg5jnFiDYczSN-uZENOP-v3Puf2rf7w%40mail.gmail.com.
Just to give some context: we worked hard to make sure that adding an extension wouldn't "break" an application. And that was a conscious decision.Now we could change that but that's not a decision that is so obvious.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/CALeTM-mdT-rTZy9cGNkJWDAqpqR-v5i%2B%3DVyNP-VvNB6cBYvBew%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/8b8d2e78-72c4-413f-91b8-d2d4cfe51687n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/CAEqagprCcW7etS1%3D%2BDYgkdWKZDdhp4qjYFcocw8EJCqOF%3D-oPw%40mail.gmail.com.
How does an application look when it's using a datasource without Hibernate?
--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/CAKU9E9u%3DaHsqxQaGQfQMgL%3Dk%2B1BTeDe0R6EN5HR8WurR%3DJeLwA%40mail.gmail.com.
On Tue, Dec 12, 2023 at 10:44 AM Stephane Epardaud <stephane...@gmail.com> wrote:How does an application look when it's using a datasource without Hibernate?
--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/CAEqagprT%2B0-Rv%3DaVX7TRshJ8WJj8_R%3D0PaGvRQT1KvYE9xgtNA%40mail.gmail.com.
More seriously:
- I know some applications do use JDBC directly, and they probably look very verbose and generally awful, but to each their own.
- For reactive datasources that's probably more common, more legitimate, and easier on the eye as the reactive SQL clients offer a more concise API.
- There are extensions in Quarkus Core that use JDBC directly without Hibernate, for things like security or storing the transaction log.
- There are probably Quarkiverse extensions that provide a different framework on top of JDBC, though I don't personally know any.
But the thing is, Reactive SQL client extensions *are* the datasource extensions. They don't *use* the datasources, they define them and provide them for use directly.Similarly, people using JDBC directly also only rely on the Agroal extension.There's no other extension at play there, so just having those extensions present doesn't tell us anything.
So we would also have to detect whether the CDI bean for a Datasource or Reactive SQL client is injected anywhere at build time.We'd effectively make the datasource beans removable, where they used to be unremovable. With the consequences we know on people who rely exclusively on `Arc.container().instance(DataSource.class)`.Same for applications that don't inject the datasource at all, but only rely on some side-effects of their existence, like health checks; though I suppose that's a weaker argument.