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

Incorrect data in the ReactiveDatasourceHealthCheck being set when the connection is down #42133

Closed
olliefreeman opened this issue Jul 25, 2024 · 2 comments · Fixed by #42260
Closed
Labels
Milestone

Comments

@olliefreeman
Copy link

Describe the bug

In


the data field for a datasource is set UP, however as this is reactive code theres a race condition existing where the checkFailures method in the same class can set the data field to DOWN before this UP data is set. This can result in the health check being DOWN but the datasource being UP.

The fix for this is actually extremely easy

Change the execute section to set the UP data if the result is not a failure, and remove the setting of this data on line 79

pgPool.query(healthCheckSQL)
            .execute { ar: AsyncResult<RowSet<Row>> ->
                if (ar.failed()) {
                    operationsError(dataSourceName, ar.cause())
                    builder.down()
                    builder.withData(dataSourceName, "DOWN - connection failed: ${ar.cause().javaClass.name} : ${ar.cause().message}")
                } else {
                    builder.withData(dataSourceName, "UP")
                }
                databaseConnectionAttempt.complete(null)
            }

Expected behavior

If the connection is down and the query can't be executed then the health check should be

{
            "name": "Reactive MySQL connections health check",
            "status": "DOWN",
            "data": {
                "<default>": "DOWN - connection failed: io.netty.channel.AbstractChannel$AnnotatedSocketException : Network is unreachable: HOST_DETAILS"
            }
        } 

Actual behavior

If the connection is down and the query can't be executed then the health check is

{
            "name": "Reactive MySQL connections health check",
            "status": "DOWN",
            "data": {
                "<default>": "UP"
            }
        } 

How to Reproduce?

  1. Create any Database server and make sure its running
  2. Start any Quarkus App with a Reactive Client e.g. implementation("io.quarkus:quarkus-reactive-mysql-client") connecting the DB from "1"
  3. Shut down the Database
  4. Query /q/health/ready endpoint

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

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

No response

Additional information

No response

@olliefreeman olliefreeman added the kind/bug Something isn't working label Jul 25, 2024
Copy link

quarkus-bot bot commented Jul 25, 2024

/cc @jmartisk (health), @xstefank (health)

@xstefank
Copy link
Member

@olliefreeman you are correct, and I think your fix is also all right. Do you fancy doing the PR for this? If not, I can fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants