Explain SHARED, UPDATE and EXCLUSIVE locks with the help of an example

DB2DatabaseBig Data Analytics

The SHARED, UPDATE and EXCLUSIVE are the types of locks which are used in concurrent application processing. This means that these locks are used when the two or more applications try to access the same row or page. Below is the description for each type of lock.

SHARED LOCK

If any application acquires SHARED LOCK on a page, then it can read that page but cannot update it. Other concurrent applications can acquire the SHARED or UPDATE lock on the same page.

UPDATE LOCK

If any application acquires UPDATE LOCK on a page, then it can read that page but cannot update it. In order to update the page, the application needs to promote the UPDATE LOCK to EXCLUSIVE LOCK. If any application has placed an UPDATE LOCK on a page, then other concurrent processes can only place SHARED locks. UPDATE/EXCLUSIVE locks cannot be placed by the concurrent processes.

EXCLUSIVE LOCK

If any application acquires EXCLUSIVE LOCK on a page, then it can access and update that page. Any other concurrent application cannot place any SHARED or UPDATE lock on the same page.

raja
Published on 30-Nov-2020 09:13:10
Advertisements