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

DataSourceHealthIndicator need timeout #4391

Closed
bohrqiu opened this issue Nov 5, 2015 · 12 comments
Closed

DataSourceHealthIndicator need timeout #4391

bohrqiu opened this issue Nov 5, 2015 · 12 comments
Labels
for: team-attention An issue we'd like other members of the team to review status: declined A suggestion or change that we don't feel we should currently apply

Comments

@bohrqiu
Copy link
Contributor

bohrqiu commented Nov 5, 2015

for the business function,we will set database timeout(get connent form pool time out or exec query wait time out ) very long ,but It's not appropriate for HealthIndicator. in HealthIndicator,We just check whether the connection is available. so we should add timeout for HealthIndicator,as DataSourceHealthIndicator an example

https://gist.github.com/bohrqiu/094e6e22a56b684fcec8

@bohrqiu
Copy link
Contributor Author

bohrqiu commented Nov 5, 2015

We'd better add timeout on org.springframework.boot.actuate.health.AbstractHealthIndicator#health method,all HealthIndicator can timeout

@philwebb philwebb added the type: enhancement A general enhancement label Nov 5, 2015
@philwebb
Copy link
Member

We're cleaning out the issue tracker and closing issues that we've not seen much demand to fix. Feel free to comment with additional justifications if you feel that this one should not have been closed.

@philwebb philwebb added status: declined A suggestion or change that we don't feel we should currently apply and removed type: enhancement A general enhancement labels Jul 27, 2018
@philwebb
Copy link
Member

It's also worth noting that as of 2.0 there is caching with health endpoints and the option of a custom TTL

@kostellodon
Copy link

Sorry, don't know the etiquette, if leaving a comment here vs creating a new issue is preferred. This is something that we need. We have a spring boot app deployed to a container (cloud foundry) that gets intermittent health check failures due to the endpoint not responding. We see no exceptions in our logs, so I'm assuming one of the health check components is taking too long to respond, but we have no way of knowing which one. Having a timeout on the health check indicators would help us track down what is causing our intermittent failures.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label May 31, 2022
@philwebb
Copy link
Member

philwebb commented Jun 1, 2022

@kostellodon Timeout support is going to be quite hard for us to implement, but your use-case makes me think that we should try to improve our logging. I've opened #31231 to track that.

@bclozel bclozel removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Jun 8, 2022
@yassenb
Copy link

yassenb commented Dec 4, 2024

@philwebb , I would like to point out that logging the timed out health checks is an improvement but still does not resolve the original issue. Imagine a Kubernetes deployment. From Kubernet's standpoint the liveness probe still just timed out, there is no additional information. One has to go and dig through the logs for warnings and attempt to correlate the timing with the time of the failed liveness probe. If a proper timeout is implemented in DataSourceHealthIndicator Kubernetes would be able to store and display the result of the HTTP request which would contain information about the failed health checks

@philwebb
Copy link
Member

philwebb commented Dec 4, 2024

Understood, but we still don't have an easy to implement timeout support I'm afraid.

@yassenb
Copy link

yassenb commented Dec 5, 2024

I'm not familiar enough with Spring internals to open a PR but where is the complication in implementing it for DataSourceHealthIndicator. If I'm not missing anything in the method

private Boolean isConnectionValid(Connection connection) throws SQLException {
	return connection.isValid(0);
}

all that's needed is to replace the 0 with something configurable, something in the lines of management.endpoint.health.db.timeout for the configuration path

@philwebb
Copy link
Member

philwebb commented Dec 6, 2024

Perhaps it's not as hard as I feared. Some vendors seem to ignore the timeout, but it looks like MySQL and Postgres support it. We'll discuss this on a team call and decide what to do.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Dec 6, 2024
@philwebb
Copy link
Member

philwebb commented Dec 9, 2024

@yassenb We talks about this on our team call and other members of the team reminded me why we didn't go down the connection.isValid(timeout) route. The problem is that we also support the use of a validation query and the JDBC API doesn't offer a timeout for calling that.

That leaves us back with the idea of running the health indicator in a background thread so we can offer a timeout. It seems like there is demand for that, and it's a more general problem than just datasource health indicators. I've opened #43449 to see what we can do.

@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Dec 11, 2024
@wilkinsona
Copy link
Member

I missed yesterday's meeting, but I wonder if configuring the query timeout on the JdbcTemplate would help here? At the moment, I think we're relying on the JDBC driver's default.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Dec 12, 2024
@philwebb
Copy link
Member

Interesting, it looks like I missed that java.sql.Statement also supports a timeout (although only in seconds). The code in DataSourceUtils.applyTimeout(...) is used by JdbcTemplate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: team-attention An issue we'd like other members of the team to review status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

6 participants