intention lock 意向锁,表明有事务正在或者打算锁住一行记录
record lock行所,分为排他锁和共享锁
gap lock锁住索引之间的间隙
next key lock :record lock + gap lock

for example
id :0,5,10,15,20,25
unique,a
index,b
select * from performance_schema.data_locks;

id=10
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
PRIMARYRECORDX,REC_NOT_GAPGRANTED10
a=10
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
test_a_uindexRECORDX,REC_NOT_GAPGRANTED10, 10
PRIMARYRECORDX,REC_NOT_GAPGRANTED10
b=10
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
test_t_indexRECORDXGRANTED10, 10
PRIMARYRECORDX,REC_NOT_GAPGRANTED10
test_t_indexRECORDX,GAPGRANTED15, 15
id=11
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
PRIMARYRECORDX,GAPGRANTED15
a=11
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
test_a_uindexRECORDX,GAPGRANTED15, 15
b=11
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
test_t_indexRECORDX,GAPGRANTED15, 15
id>11
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
PRIMARYRECORDXGRANTED0
PRIMARYRECORDXGRANTED5
PRIMARYRECORDXGRANTED10
PRIMARYRECORDX,GAPGRANTED15
id<=11
index_namelock_typelock_modelock_statuslock_data
NULLTABLEIXGRANTEDNULL
PRIMARYRECORDXGRANTED0
PRIMARYRECORDXGRANTED5
PRIMARYRECORDXGRANTED10
PRIMARYRECORDX,GAPGRANTED15

结论:
X:next key lock,也就是recordlock+ previous gap
x gap:previous gap
x rec not gap: rec


yinpursue
1 声望0 粉丝

« 上一篇
Future
下一篇 »
generic type