In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The gap lock next-key is locked for records where the range condition does not exist to avoid unrepeatable reading and phantom reading. If it is the isolation level of read committed, this problem does not exist.
So: in our development, if we use the isolation level of repeatable read, we should minimize updates to a certain range of records, otherwise it will seriously affect concurrent insertion.
Special case: applying for a lock of a record that does not exist through equal conditions will also use the next-key lock and affect the insertion of the record.
Root@sakila 10:46:49 > show variables like'% tx_isolation%'
+-+ +
| | Variable_name | Value |
+-+ +
| | tx_isolation | REPEATABLE-READ |
+-+ +
1 row in set (0.00 sec)
Session 1:
Root@sakila 10:49:04 > select * from tab_no_index where id=111 for update
Empty set (0.00 sec)
Session 2: because the first session lock record does not exist, the next-key is locked. There is no scope, which is equal to all, so the new record cannot be inserted.
Root@sakila 10:47:43 > insert into tab_no_index values (200Japanese 200')
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
Root@sakila 10:49:17 > rollback
Query OK, 0 rows affected (0.01 sec)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.