Connector/J provides a useful load-balancing implementation for Cluster or multi-master deployments. As of Connector/J 5.1.12, this same implementation is used under the hood for balancing load between read-only slaves with ReplicationDriver. When trying to balance workload between multiple servers, though, the driver has to decide when it’s safe to swap servers – doing so in the middle of a transaction would not make applications very happy. Many of the same principles which apply to autoReconnect also apply here – you don’t want to lose important state information.
As a result, Connector/J will only try to pick a new server when one of the following happen:
- At transaction boundaries (transactions are explicitly committed or rolled back)
- A communication …