kostya kote wrote:
> ok,
> I'll try to ask another way.
> Do I need to reconnect when my host was down ? If
> it is so, then I have slow performance cause
> driver try to connect all hosts starting from
> first. And each time I get latency while driver
> find the host which is up.
>
> How can I make an application such a way that I
> only once got connection and then in some
> operation loop could use it, in spite of broken
> connection with one of the host, indicated in
> connection URL ?
> I guess when I set property autoReconnect in the
> true state the driver automatically will be
> connecting to failover host listed in connection
> URL, and I have no need to recconect it at each
> transaction. Is it right ?
Kostya,
Any "in-flight" transaction when a host fails will have to be retried by _your_ application. The JDBC driver can't do it automatically because it is not safe. Only your application "knows" whether it is okay to "replay" a transaction. Placing transactions that can be re-tried in a "while" or "for" loop that exits when the transaction has been completed successfully.
A common configuration is to place these "clustered" connections in a connection pool so they are somewhat long-lived, and to have the connection pool do a liveness check (configured in your connection pool) to make sure the connection is pointing at a host that is "up" before it is handed to your application.
Currently, MySQL has no ability to "push" availability information to clients, so the only way for them to determine what host(s) are up/down is to try and connect to them.
-Mark
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html