quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.57k stars 2.63k forks source link

Support JDBC connection routing to readonly replica #25957

Open ndiaz-addepar opened 2 years ago

ndiaz-addepar commented 2 years ago

Description

This PR relates to one of the issues

A lot of people using Spring Transactional annotation use @Transactional(readonly=true) for the benefit of connection routing at the jdbc driver level

More explicitly when connecting to Aurora Mysql the url is something like this: jdbc:mysql:replication://${RW_ENDPOINT}:3306,${RO_ENDPOINT}:3306/DBNAME If the underlying connection is marked as readOnly basically calling: conn.setReadOnly(true); The Driver will automatically redirect queries to the ReadOnly EndPoint with no extra code.

Implementation ideas

Because @TransactionConfiguration already exists to setup timeouts it should be possible to also extend it to setup the readonly property in the connection. and this will unlock the use of Aurora or Replicated MySQL env for RO routing

loicmathieu commented 2 years ago

~Duplicate of https://github.com/quarkusio/quarkus/issues/6414.~ ~I'm closing this one, you can watch 6414 and provides feedback on it (vote with 👍 ).~

ndiaz-addepar commented 2 years ago

@loicmathieu I beg to differ. If you closely look at the thread these are your own words requesting to open a new issue: https://github.com/quarkusio/quarkus/issues/6414#issuecomment-802119021

I am explicitly asking for Connection to be set as read only.

loicmathieu commented 2 years ago

Sorry @ndiaz-addepar the comment was three months old and I forget it ;)

Anyway, your issue title is misleading as it's talking about readonly transaction but what you want it support for readonly replicas in a connection. I'll repoen it with a title reflecting this.

ndiaz-addepar commented 2 years ago

Sorry @ndiaz-addepar the comment was three months old and I forget it ;)

Anyway, your issue title is misleading as it's talking about readonly transaction but what you want it support for readonly replicas in a connection. I'll repoen it with a title reflecting this.

Thank you!!

kf3in commented 6 days ago

Please, at least allow keycloak to start with a readonly database