Another use for the tracker mechanism is to permit applications to know when transactions can be moved from one session to another. Transaction state tracking enables this, which is useful for applications that may wish to move transactions from a busy server to one that is less loaded. For example, a load- balancing connector managing a client connection pool could move transactions between available sessions in the pool. 

However, session switching cannot be done at arbitrary times. If a session is in the middle of a transaction for which reads or writes have been done, switching to a different session implies a transaction rollback on the original session. A session switch must be done only when a transaction does not yet have any reads or writes performed within it. 

Examples of when transactions might reasonably be switched: 

•Immediately after START TRANSACTION 

•After COMMIT AND CHAIN 

In addition to knowing transaction state, it is useful to know transaction characteristics, so as to use the same characteristics if the transaction is moved to a different session. The following characteristics are relevant for this purpose: 

READ ONLY READ WRITE ISOLATION LEVEL WITH CONSISTENT SNAPSHOT 

To support the preceding session-switching activities, notification is available for these types of client session state information: 

•Changes to these attributes of client session state: 

•The default schema (database). 

•Session-specific values for system variables. 

•User-defined variables. 

•Temporary tables. 

•Prepared statements. 

The session_track_state_change  system variable controls this tracker. 

•Changes to the default schema name. The session_track_schema  system variable controls this tracker. 

•Changes to the session values of system variables. The session_track_system_variables system variable controls this tracker. 

•Available GTIDs. The session_track_gtids  system variable controls this tracker. 

•Information about transaction state and characteristics. The session_track_transaction_info system variable controls this tracker. 

For descriptions of the tracker-related system variables, see Section 5.1.8, “Server System Variables” . Those system variables permit control over which change notifications occur, but do not provide a way to access notification information. Notification occurs in the MySQL client/server protocol, which includes 

