Forum Moderators: open

Message Too Old, No Replies

Mysql InnoDB Transaction - Why does a SELECT lock the table?

threads

         

jezzer300

11:51 pm on Nov 12, 2005 (gmt 0)

10+ Year Member



I have
- Mysql 4.0.2a
- InnoDB using the default isolation type: repeatable read
- My table (x_cart) is InnoDB and Sequence row (auto_increament) is an index.

Why does my first thread cause my second thread to wait until it's done a commit?

Thread 1 first does this...

START TRANSACTION;
SELECT * from x_cart where sequence=1;

Thread 2 then does this before thread 1 commits:

START TRANSACTION;
SELECT * from x_cart where sequence=13;

----

I'm not even asked the row to be locked "FOR UPDATE", so why does the 2nd thread/transaction have to wait for the first to commit?

jezzer300

8:28 pm on Nov 13, 2005 (gmt 0)

10+ Year Member



This problem is now fixed. Wasn't to do with the above code!