MySQL Forums
Forum List  »  General

Re: autcommit vs. manual commit behavior
Posted by: Bill Karwin
Date: May 19, 2006 03:11PM

Sounds like autocommit is disabled in session 2 as well, and your transaction isolation level is REPEATABLE READ or SERIALIZABLE. This means that the transaction in session 2 sees only data that was committed at the moment its transaction began.

Try this scenario to illustrate it:
Session 1: SET AUTOCOMMIT = 0. Make a change but do not commit yet.
Session 2: SET AUTOCOMMIT = 0. START TRANSACTION.
Session 1: COMMIT.
Session 2: SELECT to try to see the change. You should not see it, because it wasn't committed when the transaction began.
Session 2: START TRANSACTION again. Now SELECT. Now you should see the change from session 1 (it is not necessary to quit and reconnect, just start a new transaction).

Try this different scenario:
Session 1: SET AUTOCOMMIT = 0. Make a change but do not commit yet.
Session 2: SET AUTOCOMMIT = 0. SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED. START TRANSACTION.
Session 1: COMMIT.
Session 2: SELECT to try to see the change. You should see it this time, because session 2's transaction is set to be able to view data committed by other transactions as soon as they occur.

This is intended behavior, and should function the same in all versions of MySQL.

See http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-isolation.html for more details on transaction isolation levels.

Regards,
Bill K.

Options: ReplyQuote


Subject
Written By
Posted
Re: autcommit vs. manual commit behavior
May 19, 2006 03:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.