A switch or failover request can occur due to either an administrative request or a failed server.
Each thread manages its own outgoing connection and responds to these switch requests.
When a switch request is received, the thread behaves in the following manner:
If the current connection is completely idle (that is, not actively being used to communicate with a remote server, and not involved in an open transaction), the thread immediately switches the connection without any interruption of activity.
If the connection is not idle, and the switch request explicitly requests that the connection be switched immediately, or the switch request is due to a failed remote server, a deadlock message is issued to the client (indicating that the current transaction has been rolled back), and the connection is switched.
If the connection is not idle, and the switch request did not specify any limit on how long the switch is to take, the thread switches the connection as soon as the client finishes communicating with the remote server, and exits the top level transaction.