exclusive lock it is asked for by a transaction


Exclusive lock

  • It is asked for by a transaction on a data item that it wants to update.
  • No other transaction can put either a shared lock or an exclusive lock on a data item that is locked in an exclusive mode.

Let us explain the above two modes with the help of an instance. We will once again consider the transactions T1 and T2 but in addition a transaction T11 that search the total of accounts Y and Z.

Schedule

T1

T2

T11

S_Lock X

 

S_Lock X

 

S_Lock Y

 

S_Lock Y

 

Read X

 

Read X

 

S_Lock Y

 

 

S_Lock Y

S_Lock Z

 

 

S_Lock Z

 

 

 

Read Y

 

 

 

Read Z

X_Lock X

X_Lock X. The exclusive lock request on X is denied as T2 holds the Read lock. The transaction T1 Waits.

Read Y

 

Read Y

 

Display X+Y

 

Display X+Y

 

Unlock X

 

Unlock X

 

X_Lock Y

X_Lock Y. The previous exclusive lock request on X is granted as X is unlocked. But the new exclusive lock request on Y is not granted as Y is locked by T2 and T11 in read mode. Thus T1 waits till both T2 and T11 will release the read lock on Y.

Display Y+Z

 

 

Display Y+Z

Unlock Y

 

Unlock Y

 

Unlock Y

 

 

Unlock Y

Unlock Z

 

 

Unlock Z

Read X

Read X

 

 

Subtract 100

Subtract 100

 

 

Write X

Write X

 

 

Read Y

Read Y

 

 

Add 100

Add 100

 

 

Write Y

Write Y

 

 

Unlock X

Unlock X

 

 

Unlock Y

Unlock Y

 

 

                                                               Figure: Example of Locking in multiple-modes

Therefore, the locking as above results in a serialisable schedule. Now the query is can we release locks a bit early and have still no concurrency related problem?Yes, we can do it if we lock using two-phase locking protocol.

Request for Solution File

Ask an Expert for Answer!!
Database Management System: exclusive lock it is asked for by a transaction
Reference No:- TGS0210195

Expected delivery within 24 Hours