Bug #56706 Synchronize read-only state when swapping load-balanced connections
Submitted: 9 Sep 2010 22:59 Modified: 28 Sep 2010 11:05
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.13 OS:Any
Assigned to: Tony Bedford CPU Architecture:Any

[9 Sep 2010 22:59] Todd Farmer
Description:
When load-balanced connections swap servers, certain session state is copied from the previously active connection to the newly-selected connection:

* auto-commit state
* transaction isolation state
* current schema/catalog

The read-only state is *not* synchronized, which can cause problems:

1. call Connection.setAutoCommit(false);
2. call Connection.setReadOnly(true); <- sets read-only on host1 only
3. do some work
4. call Connection.commit(); <-- rebalances to host2, potentially
5. call Connection.setReadOnly(false); <-sets read-only on host2
6. do some work
7. call Connection.commit(); <-- rebalances to host1, potentially
8. do some read-write work <-fails because nost1 is still read-only

How to repeat:
See above.

Suggested fix:
Ensure read-only state is synchronized when new physical connections are chosen.
[9 Sep 2010 23:05] Todd Farmer
Fixed in r977.
[28 Sep 2010 11:05] Tony Bedford
An entry has been added to the 5.1.14 changelog:

When load-balanced connections swap servers, certain session state was copied from the previously active connection to the newly-selected connection. State synchronized included:

Auto-commit state

Transaction isolation state

Current schema/catalog

However, the read-only state was not synchronized, which caused problems if a write was attempted on a read-only connection.