Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is xlock,rowlock,holdlock correct?

I saw the combination of (xlock,rowlock,holdlock) is used for a table. Refer to online book, holdlock is to hold shared lock(for read,such as select) until transaction is done and xlock is exclusive lock(write lock) for data modification, such as update, insert or delete. How could we use read and write a table at the same time? I am wondering if the combination take effect or not. Confusing...

like image 745
FebWind Avatar asked Dec 21 '22 02:12

FebWind


1 Answers

Locking hints come in various types:

  • Granularity: rowlock, paglock, tablock
  • Lock type: nolock, updlock, xlock
  • Other hints: holdlock, readpast, nowait

The combination you suggest is xlock, rowlock, holdlock. Those three do not conflict. It'll lead to an exclusive rowlock that is held until the end of the transaction.

like image 176
Andomar Avatar answered Jan 07 '23 22:01

Andomar