Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use mysql insert intention Lock

Shulou Source: shulou.com Published: 2022-05-31 10:54:44 09月28日 Update

This article introduces the knowledge of "how to use mysql insertion intention lock". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. The insertion intention lock is a Gap lock, not an intention lock, but the result of an insert operation. When multiple transactions write different data to the same index gap at the same time, there is no need to wait for other transactions to complete, and lock waiting does not occur.

Suppose that a record index contains keys 4 and 7, and different transactions insert 5 and 6, respectively, and each transaction generates an insert intention lock, which is added to 4-7 to get an exclusive lock on the inserted row, but does not lock each other, because the data rows do not conflict.

2. Inserting an intention lock will not block any lock, and inserting a record will hold a record lock.

Example

Insert into test_user (user_id,name,age) values-TRX HAS BEEN WAITING 18 SEC FOR THIS LOCK TO BE GRANTED:RECORD LOCKS space id 6628 page no 4 n bits 72 index `index_ user`of table `test`.`test _ user` trx id 117851203 insert intention lock lock_mode X insert intention waitingRecord lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0 0: len 8; hex 73757072656d756d; asc supremum This is the end of the content of "how to use mysql insert intention Lock". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Intention transaction difference content data more knowledge index practicality achievement next between at the same time dilemma multiple instance actual situation article case Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB vpn Apple Shulou Technology