Question

In: Computer Science

Question on Database Systems - Concurrency Control A popular update operation is increment/decrement the numeric value...

Question on Database Systems - Concurrency Control

A popular update operation is increment/decrement the numeric value of data object by 1. Suppose we are now to create a lock mode I, along with usual shared and exclusive lock modes. Consider a locking protocol that will require a request for a lock with mode I on a data object Q (with numeric value) before proceeding with the increment/decrement operation on Q.
(i) Provide a lock compatibility matrix with these three modes.
(ii) Will this protocol provide more concurrency (data sharing) than the one with only shared and exclusive lock modes?
(iii) Suppose the increment/decrement operation is modified such that the operation will fail if the value of data object will become negative after the operation. Are your answers to (i) and (ii) still valid? Explain your answer.

Solutions

Expert Solution

Shared (S) locks allow concurrent transactions to read (SELECT) a resource under pessimistic concurrency control.

Update(U) lock:Update (U) locks prevent a common form of deadlock. In a repeatable read or serializable transaction, the transaction reads data, acquiring a shared (S) lock on the resource (page or row), and then modifies the data, which requires lock conversion to an exclusive (X) lock. If two transactions acquire shared-mode locks on a resource and then attempt to update data concurrently, one transaction attempts the lock conversion to an exclusive (X) lock. The shared-mode-to-exclusive lock conversion must wait because the exclusive lock for one transaction is not compatible with the shared-mode lock of the other transaction; a lock wait occurs. The second transaction attempts to acquire an exclusive (X) lock for its update. Because both transactions are converting to exclusive (X) locks, and they are each waiting for the other transaction to release its shared-mode lock, a deadlock occurs.
To avoid this potential deadlock problem, update (U) locks are used. Only one transaction can obtain an update (U) lock to a resource at a time. If a transaction modifies a resource, the update (U) lock is converted to an exclusive (X) lock.

Intent lock: The Database Engine uses intent locks to protect placing a shared (S) lock or exclusive (X) lock on a resource lower in the lock hierarchy. Intent locks are named intent locks because they are acquired before a lock at the lower level, and therefore signal intent to place locks at a lower level.

Intent locks serve two purposes:

  • To prevent other transactions from modifying the higher-level resource in a way that would invalidate the lock at the lower level.

  • To improve the efficiency of the Database Engine in detecting lock conflicts at the higher level of granularity.

For example, a shared intent lock is requested at the table level before shared (S) locks are requested on pages or rows within that table. Setting an intent lock at the table level prevents another transaction from subsequently acquiring an exclusive (X) lock on the table containing that page. Intent locks improve performance because the Database Engine examines intent locks only at the table level to determine if a transaction can safely acquire a lock on that table.

Intent locks include intent shared (IS), intent exclusive (IX), and shared with intent exclusive (SIX).

Lock Compatability:

Lock compatibility controls whether multiple transactions can acquire locks on the same resource at the same time. If a resource is already locked by another transaction, a new lock request can be granted only if the mode of the requested lock is compatible with the mode of the existing lock. If the mode of the requested lock is not compatible with the existing lock, the transaction requesting the new lock waits for the existing lock to be released or for the lock timeout interval to expire. For example, no lock modes are compatible with exclusive locks.

If a transaction Ti holds a data item N in IS’ mode and transaction Tj requests the data item N in IS mode then Tj is allowed to lock it in IS mode. i.e.
If Ti holds a data item N in IS mode means that there is some node below N in the tree which is in shared mode
And Tj requests the data item N in IS mode means that Tj is requesting some node below N in shared mode, then the request for Tj is allowed.

Lock modes in intent lock:

Intent Shared(IS):Protects requested or acquired shared locks on some (but not all) resources lower in the hierarchy.

Intent Exclusive(IX):Protects requested or acquired exclusive locks on some (but not all) resources lower in the hierarchy. IX is a superset of IS, and it also protects requesting shared locks on lower level resources.

Shared with Intent EXclusive(SIX):Protects requested or acquired shared locks on all resources lower in the hierarchy and intent exclusive locks on some (but not all) of the lower level resources. Concurrent IS locks at the top-level resource are allowed. For example, acquiring a SIX lock on a table also acquires intent exclusive locks on the pages being modified and exclusive locks on the modified rows. There can be only one SIX lock per resource at one time, preventing updates to the resource made by other transactions, although other transactions can read resources lower in the hierarchy by obtaining IS locks at the table level.

Intent Update(IU):Protects requested or acquired update locks on all resources lower in the hierachy. IU locks are used only on page resources. IU locks are converted to IX locks if an update operation takes place.

Shared Intent Update(SIU):A combination of S and IU locks, as a result of acquiring these locks separately and simultaneously holding both locks. For example, a transaction executes a query with the PAGLOCK hint and then executes an update operation. The query with the PAGLOCK hint acquires the S lock, and the update operation acquires the IU lock.

Update Intent Exclusive(UIX):A combination of U and IX locks, as a result of acquiring these locks separately and simultaneously holding both locks.

Multiple Granularity Locking Protocol: It is the hierarchically breaking up the database into portions which are lockable and maintaining the track of what to be lock and how much to be lock so that it can be decided very quickly either to lock a data item or to unlock a data item.

In order to get advantages of both ( high level granularity + low level granularity), we use Multiple Granularity which provides more concurrency.

To decrease the search a little bit, we can maintain information about the file whose any record is locked by a transaction, is maintained in lock compatible table or say some traces must be left along the path(i.e. height of the tree). So that whenever a request of Lock is arrived, we can check the table directly.


Related Solutions

SUBJECT: DATABASE SYSTEMS !!! Please answer the question as early as possible !!! Question 1 You...
SUBJECT: DATABASE SYSTEMS !!! Please answer the question as early as possible !!! Question 1 You are required to draw a complete Crow’s Foot ERD that includes the following entity relationship components based on the below descriptions: i) Identify all of the entities and its attributes. ii) Identify all possible relationships and its connectivity. iii) Identify the primary key and foreign key for each entity. iv) Identify the participation constraint and cardinality for each relationship. A Super5 company contains many...
Part A: Database research (approx. 200-250 words): (5 Marks) Research Question: Explore history of database systems...
Part A: Database research (approx. 200-250 words): Research Question: Explore history of database systems and discuss the three most important developments in database development history to date. (1.25 marks each) Note: Use proper references in the APA style. Your research report must be well presented using proper content organization. (1.25 marks)
Question with regards to Statistical Process Control. Control chart systems can operate on two basic methods...
Question with regards to Statistical Process Control. Control chart systems can operate on two basic methods of measurement. State these two methods and briefly distinguish between them, giving three examples of industrial processes where each might be applied. Specify an appropriate sampling procedure in each case.
Explain differences in culturally based value systems related to the amount of control a person feels...
Explain differences in culturally based value systems related to the amount of control a person feels he or she has over future out comes. How does this belief influence the decision making process?
This question is being asked from chapter 5 of the book electric motors and control systems...
This question is being asked from chapter 5 of the book electric motors and control systems 2nd version and the files attached. file:///C:/Users/prime/Downloads/ET55a%20Single%20Phase%20AC%20Motors%20%236B.pdf file:///C:/Users/prime/Downloads/ET55a%20Three%20Phase%20AC%20Motors%20%236A.pdf 1. What are the differences (in construction, starting torque, and operation) between “capacitor start” and “capacitor start/capacitor run” motors?
This question is being asked from chapter 5 of the book electric motors and control systems...
This question is being asked from chapter 5 of the book electric motors and control systems 2nd version and the files attached. file:///C:/Users/prime/Downloads/ET55a%20Single%20Phase%20AC%20Motors%20%236B.pdf file:///C:/Users/prime/Downloads/ET55a%20Three%20Phase%20AC%20Motors%20%236A.pdf 1. Why does an induction motor (with a squirrel cage rotor) need “slip” - operating at less than the synchronous speed (the speed in which the magnetic field rotates in the stator)?
In your own words please300 word count please answer the following question. What effective control systems...
In your own words please300 word count please answer the following question. What effective control systems does a health care organization have in place to ensure that different people with varying professional commitments and approaches are consistent with the organization's mission in a patient-centered environment?
Question 2: Traffic Control Systems makes bright rubber traffic cones. The company has two departments, Melting...
Question 2: Traffic Control Systems makes bright rubber traffic cones. The company has two departments, Melting and Forming. Raw materials are introduced at various stages throughout the melting process. The following is the department’s work in process T-Account for August:                    Work in Process – Melting Department Aug 1 balance: (200 kilograms; 80% complete as to materials, 70% complete as to conversion) 352 Completed and transferred to the packaging department (_?_ kilograms) ___?___ Costs added: Materials (2,050 kilograms) 890 Labour...
Question 1) Complex Systems has an outstanding issue of $1000 par value bonds with a 11%...
Question 1) Complex Systems has an outstanding issue of $1000 par value bonds with a 11% coupon interest rate. The issue pays interest annually and has 16 years remaining to its maturity date. a) If the bonds of similar risk are currently earning a rate of return of 9%, how much should Complex Systems bond sell for today? b) Describe the two possible reasons why the rate on similar-risk bonds is below the coupon interest rate on the Complex System...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT