Lock table under Mysql Innodb:RR level. Why write blocks select? in another transaction

I ran lock table employees write, on one transaction and then used select statements on another transaction, without for update or lock in share mode

select is said to be snapshot read, unlocked, why it is lock table. Write watch lock blocking?

Mar.01,2021

The downside to locking the tables is that no session can update a READ-locked table (including the one holding the lock) and no session can access a WRITE-locked table other than the one holding the lock.

drunk. Why do you always invite me? look through the documents
https://dev.mysql.com/doc/ref.

.

Lock write

lock table my_table_name write;

means write lock. When a write lock is acquired, no other session can read or write.

to make other session readable, use

lock table my_table_name read;

(but you can't write it yourself at this time!).

lock table my_table_name read; does not mean that you are not allowed to read. On the contrary, other conversations can be read, but not written.

or the level of lock is as follows:

lock table xxxx write > lock table xxxx read

here is a very detailed description:

https://blog.csdn.net/sunhuaq.

lock table there are two main usage scenarios: simulating transaction processing or speeding up update during batch processing.
in other cases, because InnoDB itself is a transactional engine at the time of writing, manual locking is not required.

Menu