-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Use query-less datasource validation by default #17582
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
Comments
This would not result in the same behaviour. For example, we know that we have users that are using a custom query to meet their interpretation of what it means for the
Let's consider providing an option to use |
Thank you @wilkinsona. i would suggest to use the hikariCP approach. In hikariCP if we don't specify a in the same way, if someone is not specifying a custom query for the healthIndicator, maybe it's better to just use the Besides, if it's not a custom query the We should also keep in mind that if we configure the datasource with something like Apart from some minor timing windows, this query will get executed by a simple |
We cannot be certain that is the case if the |
interesting, well, i am not sure how all datasource pools work, but at lest for hikaricp, the pool will not release a connection unless it passes the validation stage (according to it's So with a default setup, if a connection is not used within 500ms, the connection validation will run just by a in fact, after debugging this, the pool validation query is executed by the healthIndicator, even before the check query, it is executed during this block:
In any case, any improvement in this, would be welcome. |
+1 for using Currently, in our tracing, there are bunch of I like the idea that if test query is specified, then use the query; otherwise use According to hikari documentation:
We introduced similar in R2DBC-SPI, |
I've started to hack something and, given the different in behaviour, I am wondering if that wouldn't be better to have a completely separate implementation (see 89c73bc). Using |
To add a bit more context on why i ask this. We have noticed that in our database there are a lot of
select 1 from dual
queries. which is neither a heavy query or bad..but do we really need to run a query to validate the datasource?isn't a simple (with the reasonable try-catch blocks of-course)
enough?
or for extra validation
both the above 2 approaches will result in the same behaviour as the existing one with better timeout handing in some jdbc drivers (for example for oracle).
Besides, all datasource pools, are already doing validation according to their configs in an optimal way.
for example have a look at micronaut's health indicator
single simple file, database agnostic.
I believe this will simplify a lot the health check, and dba's around the world will be happy as well
If the community does not feel comfortable enough with jdbc driver validation mechanisms in general ( i don't see why not) , maybe we could add a property to control whether
datasourceHelathIndicator
should run a query, or rely on the jdbc driverisValid
method.besides, this looks like a double config problem,
we specify in one place how hikari (personally i chose the
isValid
method of the jdbc driver) validates, and then there is thedatasourceHealthIndicator
which is overriding this validation scheme.this probably fixes: #4391 . At least for oracle, as in oracle drivers, the
connection.isValid()
respects the timeout that is configured in the pool. Probably same applies in other jdbc driversThe text was updated successfully, but these errors were encountered: