failoverReadOnly is not enforced

"Burgel, Alex" <[email protected]> Thu, 8 Mar 2007 13:09:54 -0700
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
hi,

i've been playing with failoverReadOnly on 5.0.5.

i'm not sure if the way its currently implemented is safe. since it uses
the java.sql.Connection.setReadOnly() method, it is very easy for the
application, which is not aware that its connected to a slave, to reset
the readOnly setting.

for example, in spring 2.0.2 at the end of a transaction,
HibernateTransactionManager resets the connection's readOnly status. so
on that connection, after 1 transaction, you can start issuing inserts
or updates to the slave. this is obviously a bad thing.

so i think the solution is that failoverReadOnly should be strictly
enforced in some other way, so even if the application tries to
setReadOnly(false), you still wouldn't be able to insert or update on
the slave. maybe if the connection is failed over to a slave and
failoverReadOnly is true, then ignore any calls to setReadOnly ??


there is a workaround for the particular case of spring's
HibernateTransactionManager, you can set prepareConnection to false. but
i think this should be handled transparently in the driver.

thanks.

--alex

-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]