Exclusive Database Locks Question Essay Paper
The purpose of this assignment is to assess your understanding of shared and exclusive database locks.
For all discussed Examples and Scenarios, suppose that three sessions (Session 1, Session 2 and Session 3) are connected concurrently to the same database instance, and further suppose that there are three data objects (Object X, Object Y and Object Z) that can be each be locked with either a shared lock or an exclusive lock.
Examples
Example 1
If Session 1 has a shared lock on X, and Session 2 has a shared lock on Y, what would happen if Session 3 attempts to procure a shared lock on X?
The answer is that Session 3 would be granted the shared lock, because by the nature of a shared lock, it is acceptable for both Session 1 and Session 3 to have a shared lock on the same data item at the same time.
Example 2
If Session 1 has an exclusive lock on X, and Session 2 has an exclusive lock on Y, what would happen if Session 3 attempts to procure a shared lock on X?
The answer is that Session 3 would need to wait until Session 1 releases the lock on X, because by the nature of an exclusive lock, only one session at a time may have the lock. Therefore Session 3 cannot be granted the lock at the same time Session 1 has the lock, and Session 3 will need to wait until Session 1 releases the lock.
Examples
Now that we have examined a couple examples, describe what will happen in each scenario below. For each scenario, indicate, for each session, whether it procures the requested lock, waits for the lock, or creates a deadlock. Make sure to explain your reasoning.
Scenario 1
Session 1 has an exclusive lock on X and Session 2 attempts to procure an exclusive lock on X.
Scenario 2
Session 1 has a shared lock on X and a shared lock on Y, and Session 2 attempts to procure a shared lock on Y.
Scenario 3
Session 1 has an exclusive lock on X and attempts to procure an exclusive lock on Y. Session 2 has an exclusive lock on Y and attempts to procure an exclusive lock on Z. Session 3 has an exclusive lock on Z and attempts to procure an exclusive lock on X.
Scenario 4
Session 1 has a shared lock on X and Session 2 attempts to procure a shared lock on X.
Scenario 5
Session 1 has an exclusive lock on X and Session 2 attempts to procure a shared lock on X.
Scenario 6
Session 1 has a shared lock on X and attempts to procure a shared lock on Y. Session 2 has a shared lock on Y and attempts to procure a shared lock on Z. Session 3 has a shared lock on Z and attempts to procure an exclusive lock on X.
Scenario 7
Session 1 has a shared lock on X and Session 2 attempts to procure an exclusive lock on X.
Scenario 8
Session 1 has a shared lock on X, Session 2 has a shared lock on X, and Session 3 attempts to procure a shared lock on X.
Scenario 9
Session 1 has an exclusive lock on X and attempts to procure an exclusive lock on Y. Session 2 has an exclusive lock on Y and attempts to procure an exclusive lock on X.
Scenario 10
Session 1 has an exclusive lock on X and a shared lock on Y, and Session 2 attempts to procure an exclusive lock on Y.
Scenario 11
Session 1 has a shared lock on X and a shared lock on Y. Session 2 has a shared lock on Y and attempts to procure an exclusive lock on X.
Scenario 12
Session 1 has a shared lock on X and attempts to procure an exclusive lock on Y. Session 2 has a shared lock on Y and attempts to procure an exclusive lock on Z. Session 3 has a shared lock on Z and attempts to procure an exclusive lock on X.
This is the complete question and make sure there is no plagiarism found