When does a mysql innodb database add a gap or next-key lock in an RR transaction?

is the gap or next-key lock added only if the current read is performed? Or do you want to take a snapshot and add it?
how to avoid phantom reading if snapshot reading is not added?

Mar.01,2021

take a look at this article, the introduction is very clear.
https://tech.meituan.com/inno.


coincidentally, I just wrote this article to help you figure out all the locks https://codeshelper.com/a/11.

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c168-2c2fb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c168-2c2fb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?