Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

Need help for understanding why the MySQL allow to gap lock conflicting between two transactions. (3 replies)

$
0
0
Hi, I'm a developer engineering multiple servers.

Multiples servers try the next queries simultaneously.

"SELECT * FROM xxx WHERE txid = 3" FOR UPDATE;

(If it doesn't have any records, try the next)
"INSERT INTO xxx (..., txid, ...) VALUES (..., 3, ...)

There are unique constraints on txid.


When two transactions (by two servers) excute "SELECT * FOR UPDATE", they get gap lock independently, but If the one tried to "INSERT", get blocked.

So, I read the manual and found that "It is also worth noting here that conflicting locks can be held on a gap by different transactions." and "The reason conflicting gap locks are allowed is that if a record is purged from an index, the gap locks held on the record by different transactions must be merged.


I figured out why the transaction gets blocking, but still, am curious why Mysql allows conflicting gap locks? I don't understand the "merged". Can I get an explanation with an example? Thanks in advance (_ _).

Viewing all articles
Browse latest Browse all 1954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>