Choose the correct options on acquiring locks

  1. If transaction A holds X lock on row R, If transaction B requests for S lock, then B would go into wait state until A releases the lock

  2. If transaction A holds S lock on row R, If transaction B requests for S lock, then B would be granted the lock

  3. If transaction A holds X lock on row R, If transaction B requests for X lock,then B would be granted the lock.

  4. If transaction A holds S lock on row R, If transaction B requests for X lock, then B would be granted the lock


Correct Option: A,B

AI Explanation

To answer this question, you need to understand the concept of locks in the context of transaction management. Let's go through each option to understand why it is correct or incorrect:

Option A) If transaction A holds X lock on row R, If transaction B requests for S lock, then B would go into a wait state until A releases the lock. This option is correct because in most concurrency control protocols, if a transaction holds an exclusive (X) lock on a resource (row R in this case), other transactions requesting shared (S) locks will be put into a wait state until the exclusive lock is released. This ensures that only one transaction at a time can have exclusive access to a resource.

Option B) If transaction A holds S lock on row R, If transaction B requests for S lock, then B would be granted the lock. This option is correct because shared (S) locks are compatible with other shared locks. If a transaction holds a shared lock on a resource, other transactions requesting shared locks on the same resource can be granted the lock. This allows multiple transactions to access the resource simultaneously.

Option C) If transaction A holds X lock on row R, If transaction B requests for X lock, then B would be granted the lock. This option is incorrect because exclusive (X) locks are not compatible with other exclusive locks. If a transaction holds an exclusive lock on a resource, other transactions requesting exclusive locks on the same resource will have to wait until the lock is released.

Option D) If transaction A holds S lock on row R, If transaction B requests for X lock, then B would be granted the lock. This option is incorrect because exclusive (X) locks are not compatible with shared (S) locks. If a transaction holds a shared lock on a resource, other transactions requesting exclusive locks on the same resource will have to wait until the shared lock is released.

The correct answers are A and B. These options correctly describe the behavior of locks in a transactional system.

Find more quizzes: