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

Fix MySQL high availability not working in native mode #8052

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

machi1990
Copy link
Member

@machi1990 machi1990 commented Mar 21, 2020

Fixes #7936

I was able to reproduce the error and adding the missing proxy registration fixed it.

To test the fix, using the below mysql replication setup:

docker run \
--name mysql_primary \
 -p 3306:3306 \
 -e MYSQL_ROOT_PASSWORD=hibernate_orm_test \
 -e MYSQL_USER=hibernate_orm_test \
 -e MYSQL_PASSWORD=hibernate_orm_test \
 -e MYSQL_DATABASE=hibernate_orm_test \
 -e REPLICATION_USER=hibernate_orm_test \
 -e REPLICATION_PASSWORD=hibernate_orm_test \
 actency/docker-mysql-replication:5.7

And on another terminal tab, run the following command:

 docker run \
 --name mysql_secondary \
  -p 3307:3306 \
 -e MYSQL_ROOT_PASSWORD=hibernate_orm_test \
 -e MYSQL_USER=hibernate_orm_test \
 -e MYSQL_PASSWORD=hibernate_orm_test \
 -e MYSQL_DATABASE=hibernate_orm_test \
 -e REPLICATION_USER=hibernate_orm_test \
 -e REPLICATION_PASSWORD=hibernate_orm_test \
 --link mysql_primary:master \
 actency/docker-mysql-replication:5.7

Open another terminal tab and launch jdbc-mysql integration tests with the following command
cd integration-tests/jpa-mysql and then open the configuration file and edit the jdbc url so that it points to:

jdbc:mysql:replication://localhost:3306,localhost:3307/hibernate_orm_test?connectTimeout=5000&socketTimeout=5000&retriesAllDown=3&allowMasterDownConnections=true&allowSlaveDownConnections=true&loadBalanceBlacklistTimeout=10000&readFromMasterWhenNoSlaves=true`

Then running

mvn clean install -Dnative -Dtest-mysql

Should pass successfully which was not the case previously as it was throwing missing proxy registration errors.

@SchulteMarkus can you check if this fixes the error for you?

PS: The first commit adds connection clean up in native mode. Let me know what you think about it?

/cc @Sanne @geoand @gsmet

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my wheelhouse, so I'll leave the review to others who know much about the topic

@machi1990 machi1990 marked this pull request as ready for review March 21, 2020 19:44
@machi1990 machi1990 force-pushed the fix/7936 branch 2 times, most recently from 337e21a to 92828c6 Compare March 21, 2020 20:53
… in native mode

Make sure that abandoned threads are cleaned up even in native mode using the same algorithm used in
JVM mode.
Fixes quarkusio#7936

I was able to reproduce the error and adding the missing proxy registration fixed it.

To test the fix, using the below mysql replication setup:

```
docker run \
--name mysql_primary \
 -p 3306:3306 \
 -e MYSQL_ROOT_PASSWORD=hibernate_orm_test \
 -e MYSQL_USER=hibernate_orm_test \
 -e MYSQL_PASSWORD=hibernate_orm_test \
 -e MYSQL_DATABASE=hibernate_orm_test \
 -e REPLICATION_USER=hibernate_orm_test \
 -e REPLICATION_PASSWORD=hibernate_orm_test \
 actency/docker-mysql-replication:5.7
```

And on another terminal tab, run the following command:

```
 docker run \
 --name mysql_secondary \
  -p 3307:3306 \
 -e MYSQL_ROOT_PASSWORD=hibernate_orm_test \
 -e MYSQL_USER=hibernate_orm_test \
 -e MYSQL_PASSWORD=hibernate_orm_test \
 -e MYSQL_DATABASE=hibernate_orm_test \
 -e REPLICATION_USER=hibernate_orm_test \
 -e REPLICATION_PASSWORD=hibernate_orm_test \
 --link mysql_primary:master \
 actency/docker-mysql-replication:5.7
```

Open another terminal tab and launch jdbc-mysql integration tests with the following command
`cd integration-tests/jpa-mysql` and then open the configuration file and edit the jdbc url so that it points to:
```
jdbc:mysql:replication://localhost:3306,localhost:3307/hibernate_orm_test?connectTimeout=5000&socketTimeout=5000&retriesAllDown=3&allowMasterDownConnections=true&allowSlaveDownConnections=true&loadBalanceBlacklistTimeout=10000&readFromMasterWhenNoSlaves=true`
```

Then running
```
mvn clean install -Dnative -Dtest-mysql
```

Should pass successfully which was not the case previously as it was throwing missing proxy registration errors
@gsmet gsmet added this to the 1.4.0 milestone Mar 24, 2020
@gsmet gsmet merged commit 9bcd9d4 into quarkusio:master Mar 24, 2020
@gsmet
Copy link
Member

gsmet commented Mar 24, 2020

Merged, thanks. Nice work!

@machi1990 machi1990 deleted the fix/7936 branch March 24, 2020 13:58
@machi1990
Copy link
Member Author

Great thanks.

@gsmet
Copy link
Member

gsmet commented Mar 24, 2020

I backported the second commit.

@gsmet gsmet modified the milestones: 1.4.0, 1.3.1.Final Mar 24, 2020
@machi1990
Copy link
Member Author

Thanks @gsmet

@SchulteMarkus
Copy link

Solves my problem.

@gsmet
Copy link
Member

gsmet commented Mar 25, 2020

Thanks for confirming!

@machi1990
Copy link
Member Author

Solves my problem.

@SchulteMarkus , thanks for testing and confirming.

@shahmalhar
Copy link

shahmalhar commented Jun 17, 2020

Failover with mysql is not working in 1.5.0.Final, can someone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/persistence OBSOLETE, DO NOT USE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[jdbc-mysql extension] MySQL high availability datasource health check not supported in native Quarkus
6 participants